As we all know that caching is a technique to boost up the performance of a web application. So here, in this article i will demonstrate about the installation and use of memchache in a laravel web application with an example. There are some easy steps to install memcache in laravel.

There are some other cache techniques are also available like radis, we will cover those in some other article. Here we will focus only on the memcache installation and their uses in laravel.

Actually Laravel itself provides several drivers to cache your application with some database queries, views etc. So without wasting our tiem let’s have a look to the steps to install memcached and uses of this cacheing technique.

Install Memcached

Here i will install memcached on ubuntu machine. For installing memcache on your machine you will need to run the following command on your ubuntu machine.

sudo apt-get install memcached

After that you will need to install memcached php extension to use in php. So run the following command.

sudo apt-get install php-memcached

The above command will install latest php-memcached version according to php version installed in you machine. You can install this extension with specific version like

sudo apt-get install php7. 3 -memcachedorsudo apt-get install php7. 4 -memcached

Configure Memcached Driver

After installing the above things, we will need to configure memchaed driver. So just open your laravel application’s .env file and add the following line.

.env

CACHE_DRIVER=memcached

Now open config/cache.php file and add the code written below.

#laravel #install memcached #memcached in laravel

How to install Memcache In Laravel with Example
3.55 GEEK