I'd like to fail over Redis on Django, but I don't know exactly how...
Currently, the settings are as follows.
settings.py is configured as follows
CACHES={
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': [
"127.0.0.1",
"IP of Slave"
],
'OPTIONS': {
'PASSWORD': "xxxxxxxx",
'DB': 0,
}
}
}
SESSION_ENGINE = 'django.contrib.sessions.backs.cache'
SESSION_CACHE_ALIAS="default"
Basically, Django only uses the master, and I want to connect to the slave in the event of a master failure, but I don't know how to do that...
If anyone knows, could you please let me know?
I look forward to your kind cooperation.
It seems possible by combining libraries called django-redis
and redis-py-cluster
instead of the Django standard django.contrib.sessions.backends.cache
.
An example of how Redis cluster could be built has been commented on Issue, although it has not been tried on hand.
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://XXX.YYY.ZZZ.cache.amazonaws.com/0',
'OPTIONS': {
'REDIS_CLIENT_CLASS': 'rediscluster.RedisCluster',
'CONNECTION_POOL_CLASS': 'rediscluster.connection.ClusterConnectionPool',
'CONNECTION_POOL_KWARGS': {
'skip_full_coverage_check': True# AWS ElasticCache has disabled CONFIG commands
}
}
}
}
Redis Cluster support.·Issue#208·niwinz/django-redis
© 2024 OneMinuteCode. All rights reserved.