Re: [Django] #33681: Cache OPTIONS are not passed to the Redis client. (was: Redis client OPTIONS don't work as documented, which makes setting Redis timeouts difficult)

4 views
Skip to first unread message

Django

unread,
May 6, 2022, 12:24:11 AM5/6/22
to django-...@googlegroups.com
#33681: Cache OPTIONS are not passed to the Redis client.
-------------------------------------+------------------------------------
Reporter: Ben Picolo | Owner: nobody
Type: Bug | Status: new
Component: Core (Cache system) | Version: 4.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* cc: Nick Pope (added)
* type: Cleanup/optimization => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Thanks for the report. Agreed, we should pass all options to the Redis
client. Would you like to prepare a patch? It's probably enough to pass
the OPTIONS to the underlying client, e.g.

{{{#!diff
diff --git a/django/core/cache/backends/redis.py
b/django/core/cache/backends/redis.py
index e0d30784ff..51701b77b3 100644
--- a/django/core/cache/backends/redis.py
+++ b/django/core/cache/backends/redis.py
@@ -35,6 +35,7 @@ class RedisCacheClient:
db=None,
pool_class=None,
parser_class=None,
+ **options,
):
import redis

@@ -58,6 +59,7 @@ class RedisCacheClient:
parser_class = import_string(parser_class)
parser_class = parser_class or self._lib.connection.DefaultParser

+ self._options = options
self._pool_options = {"parser_class": parser_class, "db": db}

def _get_connection_pool_index(self, write):
@@ -81,7 +83,7 @@ class RedisCacheClient:
# cache client can be implemented which might require the key to
select
# the server, e.g. sharding.
pool = self._get_connection_pool(write)
- return self._client(connection_pool=pool)
+ return self._client(connection_pool=pool, **self._options)

def add(self, key, value, timeout):
client = self.get_client(key, write=True)
}}}

Marking as a release blocker as this is as a bug in the new feature.

--
Ticket URL: <https://code.djangoproject.com/ticket/33681#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages