Example Redis and Predis configuration for Drupal 7

Public

Install redis module (http://drupal.org/project/redis) and put https://github.com/nrk/predis into 'sites/all/libraries' and put these settings into settings.php file:

Get raw version
php
  1. define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/sites/all/libraries/predis-0.8/lib/');
  2.  
  3. $conf['redis_client_interface'] = 'Predis';
  4. $conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
  5. $conf['cache_class_cache'] = 'Redis_Cache';
  6. $conf['cache_class_cache_form'] = 'Redis_Cache';
  7. $conf['cache_class_cache_views'] = 'Redis_Cache';
  8. $conf['cache_class_cache_page'] = 'Redis_Cache';
  9. $conf['cache_class_cache_menu'] = 'Redis_Cache';
  10. $conf['cache_class_cache_path'] = 'Redis_Cache';
  11. $conf['cache_class_cache_entity_node'] = 'Redis_Cache';
  12. $conf['cache_class_cache_entity_taxonomy_term'] = 'Redis_Cache';
  13. $conf['cache_class_cache_entity_taxonomy_vocabulary'] = 'Redis_Cache';
  14. $conf['cache_class_cache_entity_file'] = 'Redis_Cache';
  15. $conf['cache_class_cache_entity_user'] = 'Redis_Cache';
  16. $conf['cache_class_cache_filter'] = 'Redis_Cache';
  17. $conf['cache_class_cache_admin_menu'] = 'Redis_Cache';
  18. $conf['cache_class_cache_bootstrap'] = 'Redis_Cache';
  19. $conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
  20. $conf['redis_client_base'] = 1;
  21. $conf['cache_class_cache_field'] = 'Redis_Cache';

Comments

Grace's picture

cache_class_cache_form should never go to Redis. You should always use:

$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

Especially when you define Redis as a default backend with:

$conf['cache_default_class'] = 'Redis_Cache';

timonweb's picture

Hi Grace, why? Because it can get big? Well, any table cache can get big. Everything depends on how many RAM you give your Redis.

Grace's picture

Hi Tim. It is not about the size of that bin. It will break many forms because Redis is not a reliable backend for this kind of bin. Just try it out and pay attention what happens. Particularly, it will break all multi-step forms.