Opened 4 years ago

Last modified 3 years ago

#32076 closed New feature

Adding async methods to BaseCache — at Initial Version

Reported by: Andrew Chen Wang Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Normal Keywords: cache
Cc: Andrew Godwin, Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I've recently created a new package for Redis and Django integration at django-async-redis. I'd like to add the missing methods, e.g. get_async or set_async to the BaseCache so people can get type hints or autocompletion suggestions when using django.core.cache.cache with async.

Additionally, in order to be compatible with the async methods, there would need to be a new async method for closing cache connections/pools at django.core.cache.backends.base. I believe the only good solution to that would be:

async def close_caches_async(**kwargs):
    # Some caches -- python-memcached in particular -- need to do a cleanup at the
    # end of a request cycle. If not implemented in a particular backend
    # cache.close is a no-op
    for cache in caches.all():
        await cache.close_async()

Please let me know if that is out of scope though. I also believe implementing async methods for the current backends is also out of scope of this ticket (and my time :P).

For reference, the Google Group Discussion: here and here

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top