What do I need to do in order to serve config entities from Mongo and cache from Redis database backends?

So basically: a) how do I tell Drupal that I want to use different db backend for certain tables? b) what is needed in regard to drivers for those database backends? Are they available?

This is similar to How can I save/load my Entity from a different database in Drupal 8? but in this case I am interested in entirely different db backend + I want to include also non-entity tables so that annotation approach is not working for me.

  • Did you find a way to separate the tables using different db backends ?
    – SkyRar
    Jan 4, 2019 at 9:04

1 Answer 1


That's actually more than one question because the answer is different.

To use redis as the cache, you can use our port on github: https://github.com/md-systems/redis

The README isn't been fully updated yet but the quickstart part tells you how to configure it (after enabling the module):

  $settings['redis.connection']['interface'] = 'PhpRedis'; // Can be "Predis".
  $settings['redis.connection']['host']      = '';  // Your Redis instance hostname.
  $settings['cache']['default'] = 'cache.backend.redis';

To use redis for the cache tags checksum service, which most cache backends use, you need to override a service, for example in sites/default/services.yml, add the following:

To use the redis cache tag checksum implementation, put this in sites/default/services.yml or any other yml file that is loaded after core.services.yml:

    class: Drupal\redis\Cache\RedisCacheTagsChecksum
    arguments: ['@redis.factory']
      - { name: cache_tags_invalidator }

In the same way, you can replace any service that is defined in the core or one of the module services.yml files with a different implementation, for example some of the mongodb service implementations provided by https://www.drupal.org/project/mongodb.

In general, you don't think in terms of tables but services and API's, and you either replace them directly or by configuration he factory service (cache/key value/queue/...)

  • Thanks. But how about the config/config entities? Or just using the Mongodb module will do it?
    – user21641
    Aug 17, 2015 at 6:25
  • Also why is the Redis labeled as checksum invalidator? Why not cache backend? And where is the cache.backend.redis defined? Is there a documentation page that would give me some guidance in this topic on d.o?
    – user21641
    Aug 17, 2015 at 7:21
  • Redis isn't labeled as that. Redis provides both. It provides a checksum service that uses redis and it provides a cache backend. I explained how both of those can be set and you probably want to configure both. But you can also use one of them.
    – Berdir
    Aug 17, 2015 at 7:26
  • I gave you the generic answer for Mongodb, that you need to replace the config storage service. I don't know how well it really works at the moment, but you should be able to find more documentation in the module.
    – Berdir
    Aug 17, 2015 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.