1

I have configured 2 Drupal servers to share the same Redis cache. One of the Drupal servers is being used for editors within the local network, the second server is used to serve up guest traffic. However, I noticed that Redis is storing cached based on the host key, so each of the two servers is storing separate keys in Redis.

What Redis configuration would be used to have it share the same keys and either override hostname to a single host or have it not use host as the key?

0
3

If you use the Redis module for Drupal, you can set the database and prefix used by your sites. The default Redis database is 0 (so multiple sites use the same database) but the default prefix is the HTTP_HOST variable (so multiple sites use different prefix). You can however, set a shared prefix on both site in their settings.php:

$conf['cache_prefix']['default'] = 'mysite_';

You can also set prefix per cache bin, to only share a subset of the cache between them. See Redis module's README.txt for more details.

Of course, this should only be done if your are sure the cache can actually be shared. In your case, I guess the sites share the database and are used to balance the load.

-1

I am not sure if thats a good idea and if it will ever work (there might be a reason caches are namespaced per host)

There is nothing you can do at Redis level to do what you want, you have to change the way Drupal creates cache keys (drop the hostname prefix).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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