Prevent Redis Cache from clearing ALL keys We are using the Redis module and Redis Database as cache with the following setup:

$conf['redis_client_interface'] = 'PhpRedis';
$conf['redis_client_host']      = 'redis.internal';
$conf['lock_inc']               = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['cache_backends'][]       = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_default_class']    = 'Redis_Cache';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';


Also we have our custom module that writes some keys to the database as well.

The problem is that periodically entire redis cache is cleared out ( flushed ) together with our custom keys...

How do we prevent that ?

Can Redis Cache just handle its own keys ?
You can set your default Drupal key up (in settings.php) then have your custom keys set to not expire or last longer. 

$conf['cache_prefix'] = array('default' =&gt; 'your-redis-key');


See Redis config file for documentation on how to setup max memory and such: https://raw.githubusercontent.com/antirez/redis/2.8/redis.conf

By doing this you would be setting up the policies that Redis will use to clear the cache out and what to clear. It has to clear eventually or it will become unstable, it's just cache after all :) I wouldn't be depending on it to stay that's for sure.