Skip to content

Instantly share code, notes, and snippets.

@keopx
Created April 2, 2017 08:24
Show Gist options
  • Save keopx/1618ceaf124fa26f1d610b9254b5732f to your computer and use it in GitHub Desktop.
Save keopx/1618ceaf124fa26f1d610b9254b5732f to your computer and use it in GitHub Desktop.
Drupal backend cache memcache OR redis.
<?php
# KO memcache: http://cgit.drupalcode.org/memcache/tree/README.txt?h=8.x-2.x
//$settings['memcache']['servers'] = ['memcached:11211' => 'default'];
//$settings['memcache']['bins'] = ['default' => 'default'];
//$settings['memcache']['key_prefix'] = '';
/**
* Memcache Configuration.
*/
/*
$settings['memcache'] = [
'servers' => [
'memcached:11211' => 'default',
],
'bins' => [
'default' => 'default',
],
'key_prefix' => '',
];
$settings['cache']['default'] = 'cache.backend.memcache';
$settings['cache']['bins']['render'] = 'cache.backend.memcache';
*/
# OK http://cgit.drupalcode.org/redis/tree/README.md
/**
* Redis Configuration.
*/
$settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".
$settings['redis.connection']['host'] = 'redis'; // Your Redis instance hostname.
$settings['redis.connection']['port'] = '6379'; // Redis port
# Use for all bins otherwise specified.
$settings['cache']['default'] = 'cache.backend.redis';
# Use this to only use it for specific cache bins.
$settings['cache']['bins']['render'] = 'cache.backend.redis';
/*
// Custom enabled/disabled redis cache.
$conf['custom_redis_cache_enabled'] = TRUE;
if (isset($conf['custom_redis_cache_enabled']) && $conf['custom_redis_cache_enabled']) {
$settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".
$settings['redis.connection']['host'] = 'redis'; // Your Redis instance hostname.
$settings['redis.connection']['port'] = '6379'; // Redis port
# Use for all bins otherwise specified.
$settings['cache']['default'] = 'cache.backend.redis';
# Use this to only use it for specific cache bins.
$settings['cache']['bins']['render'] = 'cache.backend.redis';
// Note that unlike memcached, redis persists cache items to disk so we can
// actually store cache_class_cache_form in the default cache.
$conf['cache_class_cache'] = 'Redis_Cache';
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment