AWS’s ElastiCache service is a convenient way to launch a Redis cluster. If you’re using Django, both django-redis-cache and django-redis packages support an ElastiCache Redis instance. If you are launching ElastiCache Redis with any amount of replicas, some additional master-slave configuration is needed in your Django settings.
Here is an example of an ElastiCache Redis cluster with a primary instance and two replicas:
The following is an example of the correct settings for this cluster if you’re using django-redis-cache backend:
CACHES = { 'default': { 'BACKEND': 'redis_cache.RedisCache', 'LOCATION': [ "test-001.730tfw.0001.use1.cache.amazonaws.com:6379", "test-002.730tfw.0001.use1.cache.amazonaws.com:6379", "test-003.730tfw.0001.use1.cache.amazonaws.com:6379" ], 'OPTIONS': { 'DB': 0, 'MASTER_CACHE': "test-001.730tfw.0001.use1.cache.amazonaws.com:6379" }, } }
https://django-redis-cache.readthedocs.io/en/latest/advanced_configuration.html#master-slave-setup
Hi Nick,
I have a similar master slave set up for redis and i am using Django redis cache.
I have 1 master and 2 slave in location settings file. How do i connect to only slave if required?
Sorry, been a while since I used anything relating to this. My guess is that this is all handled internally within django-redis-cache.