﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32076	Adding async methods to BaseCache	Andrew Chen Wang	Andrew Chen Wang	"I've recently created a new package for Redis and Django integration at [https://github.com/Andrew-Chen-Wang/django-async-redis 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 [https://github.com/django/django/blob/999cddd58d30469f3ee85278985313fdf528323d/django/core/cache/__init__.py#L116-L121 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). Edit: on second thought, I will add the methods to DummyCache as well.

For reference, the Google Group Discussion: [https://groups.google.com/forum/#!topic/django-developers/sGq5Bnc2JMg here] and [https://groups.google.com/forum/#!topic/django-developers/NX03LNahZPo here]

Edit: I've decided to add the three main cache backends -- BaseCache, DummyCache, LocMemCache -- with the necessary test cases which can be used for all future async test cases for stuff like DBCache. Please read the latest commit for which test cases are notable exceptions to the main BaseCacheTests mixin."	New feature	closed	Core (Cache system)	dev	Normal	fixed	cache	Andrew Godwin Carlton Gibson	Ready for checkin	1	0	0	0	0	0
