WebFaction
Community site: login faq

Hi everyone,

I'm currently experimenting with memcached and Redis for caching on Drupal 6. I like Redis because it has persistance. However, when I shutdown Redis, Drupal fails to load. I liked how the Drupal memcached module gracefully falls back to standard Drupal DB caching in the event that it's not available. Is there any way I can configure this for Redis? I thought of possibly doing a "ps -A | grep redis" in my Drupal settings.php file in an IF statement where redis is enabled, but that seems kind of hacky, and I don't even know if it will work. Is there a cleaner solution?

FYI, here is my settings.php:

$conf['cache_inc'] = 'sites/all/modules/cache_backport/cache.inc';

$conf['redis_client_host'] = '127.0.0.1';
$conf['redis_client_port'] = 24253;

$conf['cache_prefix'] = 'mysite_redis';

$conf['redis_client_interface']      = 'Predis';

$conf['cache_backends'][]            = 'sites/all/modules/redis/redis.autoload.inc';

$conf['cache_default_class']            = 'Redis_Cache'; 
$conf['cache_class_cache']              = 'Redis_Cache';
$conf['cache_class_cache_block']        = 'Redis_Cache';
$conf['cache_class_cache_content']      = 'Redis_Cache';
$conf['cache_class_cache_filter']       = 'Redis_Cache';
$conf['cache_class_cache_form']         = 'Redis_Cache';
$conf['cache_class_cache_menu']         = 'Redis_Cache';
$conf['cache_class_cache_page']         = 'Redis_Cache';
$conf['cache_class_cache_rules']        = 'Redis_Cache';
$conf['cache_class_cache_views']        = 'Redis_Cache';
$conf['cache_class_cache_views_data']       = 'Redis_Cache';

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

Thanks very much!

asked 29 Oct '12, 15:19

sb56637
13813
accept rate: 0%

edited 29 Oct '12, 15:22

I'm not aware of this functionality existing in Redis currently, although it might exist, and in any case it's not as clean or transparent as the memcached module. I looked but did not see an open issue for this on the Drupal site; there's only an open inquiry there created by yourself.

As for using a process grep, that is a big hacky but may work in the meantime until this is solved more elegantly. In such a case, I would not recommend "ps -A | grep redis", but maybe something more like "ps -u $USER -f | grep redis" in order to only search your own processes.

(29 Oct '12, 20:27) ryans ♦♦

Thanks, I might give that a shot.

One issue with grep is that usually (but now always) the ps command picks up the grep command itself. When I do:

ps -u myself -o rss,etime,pid,command | grep redis-server

it returns:

23764 04:38 15964 ./redis-server redis.conf

872 00:00 26528 grep redis-server

So how do I grep my way around grep? :)

(29 Oct '12, 21:18) sb56637

It's not very elegant, but almost everyone ends up doing something like this:

ps -u myself -o rss,etime,pid,command | grep 'redis-server' | grep -v 'grep'

So when you say "grep your way around grep" - indeed.

(29 Oct '12, 21:36) ryans ♦♦

Thanks very much Ryan! I really appreciate it.

(29 Oct '12, 22:53) sb56637

I ended up using this hack in my settings.php:

exec("redis-cli -h 127.0.01 -p 22253 ping", $output); 
if ($output[0]=="PONG") {

    # All the code to configure Druapl to use Redis for caching. 
}
permanent link

answered 31 Oct '12, 11:34

sb56637
13813
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×63
×12
×8

question asked: 29 Oct '12, 15:19

question was seen: 4,911 times

last updated: 31 Oct '12, 11:34

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM