Changes between Version 1 and Version 2 of Ticket #33681


Ignore:
Timestamp:
May 5, 2022, 10:09:56 AM (2 years ago)
Author:
Ben Picolo
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33681 – Description

    v1 v2  
    33I discovered unintentionally that there's no default socket_timeout set for Redis cache connections. This is an issue on it's own (unsafe default that's a particularly hard issue to track down), but in trying to set those timeouts, I hit some tough edges of documentation/usage.
    44
    5 The cache documentation says that, for caches backed by third-party libraries, the OPTIONS object [https://docs.djangoproject.com/en/4.0/topics/cache/#:~:text=cache%20backends%20backed%20by%20a%20third%2Dparty%20library%20will%20pass%20their%20options%20directly%20to%20the%20underlying%20cache%20library is passed to the underlying library connection object]. This is reaffirmed for the redis cache specifically [https://docs.djangoproject.com/en/4.0/topics/cache/#:~:text=The%20Memcached%20and%20Redis%20backends%20pass%20the%20contents%20of%20OPTIONS%20as%20keyword%20arguments%20to%20the%20client%20constructors here].
     5The cache documentation says that the OPTIONS object is passed to the third-party connection class for connections backed by third-party libraries [https://docs.djangoproject.com/en/4.0/topics/cache/#:~:text=cache%20backends%20backed%20by%20a%20third%2Dparty%20library%20will%20pass%20their%20options%20directly%20to%20the%20underlying%20cache%20library is passed to the underlying library connection object]. This is reaffirmed for the redis cache specifically [https://docs.djangoproject.com/en/4.0/topics/cache/#:~:text=The%20Memcached%20and%20Redis%20backends%20pass%20the%20contents%20of%20OPTIONS%20as%20keyword%20arguments%20to%20the%20client%20constructors here].
    66
    7 Right now, though, these OPTIONS are passed to the [https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/django/core/cache/backends/redis.py#L30 first-party RedisCacheClient object], so you can't pass in options expected by the redis connection pool [https://github.com/redis/redis-py/blob/master/redis/connection.py#L1283 link].
     7Right now, though, these OPTIONS are passed to the [https://github.com/django/django/blob/7119f40c9881666b6f9b5cf7df09ee1d21cc8344/django/core/cache/backends/redis.py#L30 first-party RedisCacheClient object], so you can't pass in options expected by the redis connection pool [https://github.com/redis/redis-py/blob/master/redis/connection.py#L1283 link]. In that sense, RedisCacheClient is being treated as a "first-party" cache according to these docs, but it defers directly to the redis library.
    88
    99One could do a variety of subclassing to make this work, but there's quite a few layers of indirection here, so it's hard to identify exactly what one should subclass in order to get arguments to the connection class appropriately.
Back to Top