Opened 3 years ago

Last modified 5 weeks ago

#33573 assigned New feature

Add native async support to redis cache backend — at Version 4

Reported by: Christopher Bailey Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: Andrew Chen Wang, Andrew Godwin, Carlton Gibson, Ülgen Sarıkavak, amirreza Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Christopher Bailey)

Do you have an idea for implementation? As far as I'm aware this would require initializing two redis clients: async and non-async.

I kind of started to implement it, but then realized it was likely going to be a bigger issue then I though. But there is already an abstract RedisClient class that is a wrapper around the base redis.Redis class. It maintains connection polls and handles all of the core commands. It has methods for get, set, add, touch, incr that just calls get_client and makes a new client using the existing connection pull any time it is called.

For Async we can just add something like get_async_client and follow the same pattern within the class. I believe the connection poll should be able to be reused between the sync/async clients.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • Unknown. The Someday/Maybe triage stage is used to keep track of high-level ideas or long term feature requests.

    It could be an issue that's blocked until a future version of Django (if so, Keywords will contain that version number). It could also be an enhancement request that we might consider adding someday to the framework if an excellent patch is submitted.

    If you're interested in contributing to the issue, raising your ideas on the Django Forum would be a great place to start.

Change History (4)

comment:1 by Mariusz Felisiak, 3 years ago

Cc: Andrew Chen Wang Andrew Godwin Carlton Gibson added
Triage Stage: UnreviewedAccepted

Tentatively accepted. Do you have an idea for implementation? As far as I'm aware this would require initializing two redis clients: async and non-async.

comment:2 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedSomeday/Maybe

Let's wait for the final release first.

comment:3 by Andrew Chen Wang, 3 years ago

We are currently re-implementing the async client (one last time) in a way that allows for aioredis 1.3.1 performance. https://github.com/seandstewart/redis-py-sansio/blob/main/benchmark/conftest.py The RedisLab team will need to approve it first, so I would wait until our new client is either approved/denied https://github.com/redis/redis-py/issues/2039. This won't affect the non-async client as the non-async client will still default on the current redis-py interface with the option to also use the new API.

This isn't to say no one should try implementing the async client now; I have high confidence the new client will be merged in with Redis-py as we're gunning for the much-needed performance gain. Just don't be surprised if a few things shift around.

comment:4 by Christopher Bailey, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top