Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

Drupal Memcache | Setup Tutorial

by | Nov 15, 2022

Memcache enhances Drupal app performance by removing standard caches from the DB and caching the results of other time-consuming DB operations. Bobcares, as a part of our Server Management Services, offers solutions to every query that comes our way.

Memcache on Drupal

Memcache improves the performance of dynamic websites by caching data and objects in RAM, reducing the number of times to read an external data source. When setting up, we must consider three things:

  • The cache bins that will be dumped with Memcache
  • Website traffic and volume
  • Amount of RAM needed
drupal memcache

Memcache is not supported in Drupal by default. So, let’s look at how to install it on the server and set it up with Drupal to reduce DB load with each page load.

Installation

1. Run the below codes in the terminal on the local machine:

sudo apt-get update
sudo apt install memcached
sudo apt install php-memcached

2. To confirm Memcache daemon is working fine, we can run the below code:

“ps aux | grep memcached”

3. Create an info.php page to see if the Memcached extension is properly setup in PHP7.

nano /var/www/html/memcache/info.php

Then enter the below code.

4. Relaunch both Memcached and php7-fpm services using the code:

service memcached restart
service php7.0-fpm restart

5. Now go to the info.php using any browser using the below code and search for “Memcache”.

localhost/memcache/info.php

After installing Memcache on the server, download and enable the Memcache module and Memcache Storage module.

Setup

1. Open the website’s settings.php file and add the code below.

// Set’s default cache storage as Memcache and excludes database connection for cache
$settings['cache']['default'] = 'cache.backend.memcache_storage';
// Set’s Memcache key prefix for your site and useful in working sites with same memcache as backend.
$settings['memcache_storage']['key_prefix'] = '';
// Set’s Memcache storage server’s.
$settings['memcache_storage']['memcached_servers'] = ['127.0.0.1:11211' => 'default'];

2. To debug Memcache, add the below code to settings.php after the above code.

// Enables to display total hits and misses
$settings['memcache_storage']['debug'] = TRUE;

We must also remember to comment/delete the Memcache settings code from the settings.php file before uninstalling Memcache.

[Looking for a solution to another query? We are just a click away.]

Conclusion

To summarize, we provide the steps to install and set up Memcache in drupal through this article.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.