Hereis the relevant part of my settings.py
:
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': env.str("REDIS_URI"),
'OPTIONS': {
'DB': 1,
'SOCKET_TIMEOUT': 5,
'SOCKET_CONNECT_TIMEOUT': 5,
'CONNECTION_POOL_CLASS': 'redis.BlockingConnectionPool',
'CONNECTION_POOL_CLASS_KWARGS': {
'max_connections': 50,
'timeout': 20},
'PICKLE_VERSION': -1,
},
},
}
I'm moving the above configruation to django-environ:
env REDIS_URL=rediscache://127.0.0.1:6379/1client_class=redis_cache.RedisCache&default_timeout=360
How can I add the connection URL from REDIS_URL
to Django's DATABASES
?
First of all you are missing a
?
in the URL parameters:Second, it is all described in the docs.
In your case:
CACHE_URL
needs to be set as environment variable.If you insist on using
REDIS_URL
you can do the following:Other options can be added using URL parameters.