0

We have the D7 Redis module installed, which is being used as the cache mechanism for D7 caching. That module uses PhpRedis as the underlying library.

I would like to use that same Redis instance to cache a large amount of non-Drupal data that is retrieved from an external API, then will be rendered on a specific Drupal page. I'm wondering how I can get ahold of the Redis object instance that Drupal is already using, so I can use PhpRedis functions like $redis->set(key,value)?

1

Once configured/initialized, the module has a wrapper class/interface Redis_Client that contains the library object. It can be retrieved with the getClient() method:

$redis = Redis_Client::getClient()

| improve this answer | |
  • Thanks, that works. I was attempting to use new Redis() but that doesn't connect to the existing Redis data store. – North Krimsly Apr 18 '19 at 20:41

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.