As it currently stands, django-redis-metrics offers basic Redis support for a single connection to a single Redis database. While this is fine for simple standalone installations, it does not support environments where something like Redis Sentinel is being used for multiple master/slave discovery.
django-redis has support for arbitrary Redis connection classes, so that different classes can be plugged into the cache system to allow it to take advantage of things like Redis Sentinel or Hiredis.
django-redis also exposes a simple django_redis.get_redis_connection() which will return whatever Redis client is configured in your cache configuration.
I propose a feature which can take advantage of this:
Add an option to the REDIS_METRICS setting called CONNECTION_CLASS, which defaults to None.
If present, this will ignore all other Redis-related options and simply call the function defined in the setting to obtain a Redis client
This will call get_redis_connection() from the django_redis package to get a Redis client (which in turn may have something like django-redis-sentinel configured as its own default client class). You may of course use your own class/function, as long as it returns a Redis client.
I will make a PR for this functionality as it is relatively straightforward to implement.
As it currently stands,
django-redis-metrics
offers basic Redis support for a single connection to a single Redis database. While this is fine for simple standalone installations, it does not support environments where something like Redis Sentinel is being used for multiple master/slave discovery.django-redis
has support for arbitrary Redis connection classes, so that different classes can be plugged into the cache system to allow it to take advantage of things like Redis Sentinel or Hiredis.django-redis
also exposes a simpledjango_redis.get_redis_connection()
which will return whatever Redis client is configured in your cache configuration.I propose a feature which can take advantage of this:
REDIS_METRICS
setting calledCONNECTION_CLASS
, which defaults toNone
.Here's an example:
This will call
get_redis_connection()
from thedjango_redis
package to get a Redis client (which in turn may have something likedjango-redis-sentinel
configured as its own default client class). You may of course use your own class/function, as long as it returns a Redis client.I will make a PR for this functionality as it is relatively straightforward to implement.