sebleier / django-redis-cache

A Redis cache backend for django
http://django-redis-cache.readthedocs.org/en/latest/
Other
1.04k stars 223 forks source link

Retry option? #208

Closed jacobg closed 2 years ago

jacobg commented 2 years ago

It looks like redis-py supports retry. Can that be incorporated into the django cache backend implementation? https://redis-py.readthedocs.io/en/stable/retry.html

jacobg commented 2 years ago

It looks like we can pass this in options:

CACHES = {
       "default": {
           "BACKEND": "redis_cache.RedisCache",
           "LOCATION": "<IP ADDRESS>:6379",
           # https://django-redis-cache.readthedocs.io/en/latest/advanced_configuration.html#socket-timeout-and-socket-create-timeout
           'SOCKET_TIMEOUT': 5,
           'SOCKET_CONNECT_TIMEOUT': 5,
           # Default connection pool is redis.ConnectionPool.
           # It defaults to 50 max connections, which is sufficient.
           # If there are no more connections, a redis.ConnectionError will be raised which we can monitor.
           'CONNECTION_POOL_CLASS_KWARGS': {
                # Will retry once without backoff.
                # https://github.com/redis/redis-py/blob/4b0543d567aef36ac467ce495d831a24575d8d5b/redis/connection.py#L558
                'retry_on_timeout': True
           }
       }
    }

Closing issue.