3

I am up to here in drupal documentation :

Start at least one instance of memcached on your server. Edit settings.php to make memcache the default cache class, for example: $conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc'; $conf['cache_default_class'] = 'MemCacheDrupal'; $conf['memcache_key_prefix'] = 'something_unique';

Why do I need a memcache key prefix if have only one database? Anyway where and how do I set it?

2 Answers 2

6

All those settings are added to settings.php

usually sites/default/settings.php

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'k1';
// Use database for cache_form
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

You only need a memcache key prefix if you're using memcache with more than one site on that server. Adding a short key, e.g $conf['memcache_key_prefix'] = 'k1'; is good practice.

3
  • Thank you. I didn't use a prefix and also used the following which has it up and running:include_once('./includes/cache.inc'); include_once('./sites/all/modules/memcache/memcache.inc'); $conf['cache_default_class'] = 'MemCacheDrupal';
    – Ann
    Jan 14, 2013 at 10:28
  • 1
    If you have a larger site and don't want AJAX or form cache functionality to break, add this as well: $conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; Dec 4, 2014 at 17:36
  • @StevenLinn, thanks, cache_form exclusion rule added for completeness. Jan 23, 2015 at 9:48
1

Solution for Drupal 8: (also in settings.php)

$settings['memcache']['key_prefix'] = 'something_unique';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.