#32076: Adding async methods to BaseCache
-------------------------------------+-------------------------------------
Reporter: Andrew Chen Wang | Owner: nobody
Type: New feature | Status: new
Component: Core (Cache system) | Version: master
Severity: Normal | Resolution:
Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrew Chen Wang):
* version: 3.1 => master
Old description:
> 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).
>
> 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]
New description:
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]
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32076#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.45b4b9b65a4409753c3f5d66338f1ee5%40djangoproject.com.