This blog post about Redis implementation on a Drupal 7 website is written by our guest blogger and Drupal addict Bas Vredeling (codeculture.nl). He wrote and published a short dutch tutorial on how to configure Redis cache on a Drupal 7 site on our hosting platform. backlink
Hosting provider Byte has implemented a caching service Redis. Cache is served directly from memory and therefore much faster than Drupal native file cache or database caching methods. Redis can be compared with other caching mechanisms such as Memcache and APC.
Installation and configuration of Redis on a Drupal 7 based website is a piece of cake. Follow the steps below and you’ll be an active user of Redis in no time. You’ll gain significant speed boost for requests in cache. A quick benchmark showed me 20% speed improvement for anonymous visitors. When you’re going to cache specific Drupal blocks even your logged in users might profit from these speed improvements.
Here’s how to install Redis on Drupal 7 at Byte:
- download and install Redis module https://drupal.org/project/redis. I prefer /sites/all/modules/contrib/redis (change path settings when installing somewhere else)
- when using Redis from Byte you’ll receive server name, port and password. You’ll need them in the configuration of Redis. These settings can be found on the Redis page of Byte control panel.
- change settings.php of the website you’re activating Redis on. Mostly it’s /sites/default/settings.php.
- add the following lines at the bottom of settings.php:
1234567891011121314/*** Redis module configuration*/$conf['redis_client_interface'] = 'PhpRedis';$conf['cache_backends'] = 'sites/all/modules/contrib/redis/redis.autoload.inc'; // Neem de installatie-directory van je redis module$conf['cache_class_cache'] = 'Redis_Cache';$conf['cache_class_cache_menu'] = 'Redis_Cache';$conf['cache_class_cache_bootstrap'] = 'Redis_Cache';$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc'; // installation directory of your Redis module$conf['redis_client_host'] = 'cache012345'; // server name from step 2$conf['redis_client_port'] = 12345; // port from step 2$conf['redis_client_base'] = 0; // 0 or 1 -> Byte uses two Redis databases$conf['redis_client_password'] = "*******************"; // password from step 2$conf['cache_prefix']['default'] = '******'; // prefix when you're using multiple websites on one caching database
- Check the status of Redis module from Byte controle panel in status reports of your Drupal site: http://example.com/
- Empty Redis cache on Byte control panel…. just to be sure. Especially if you have used other cache methods.
- Read README.txt, README.php and Redis.txt from the module directory for more configuration settings.
- Enabling the module is not strictly necessary for its operation.
- Enabling the module allows you to use a configuration page on http://example.com/admin/
- Note: this configuration page will not work since we’ve forced it’s settings in settings.php using the tutorial above.
- Redis cache will me more effective when you cache more Drupal elements. For instance: entitycache, authcache, views_content_cache, panels_page_cache, panels_hash_cache en cache_actions.
- Read the Drupal documentations for more options about caching: https://drupal.
- Note: using multiple caching options can conflict. It’s useless to use both memcache and Redis.
- Note: caching your website will improve performance. But actions such as site configuration, editing, per-user content and testing might make your site more complex when you forget that you’re looking at a page from cache rather than a fresh new page.
Meer lezen over Redis: