Async Django Cache - Redis Complete

307 views
Skip to first unread message

Andrew Wang

unread,
Oct 6, 2020, 2:25:56 PM10/6/20
to Django developers (Contributions to Django itself)
Hi all,

1.5 weeks ago, I posted that I was interested in making Django's cache async. Just here to report that the package for django-async-redis is on pypi and the repo is here: https://github.com/Andrew-Chen-Wang/django-async-redis. Please test it out. I have only tested it on a local Django project with uvicorn as a test server.

Regarding edge cases from our previous conversation, there were none that I could see. I've stuck with the naming scheme get_async rather than async_get. I think I'll leave it like that for the foreseeable future (I didn't feel a difference in typing speed, either).

My only concern is cache.close() which can be fixed in a PR for adding cache.close_async in BaseCache: https://github.com/django/django/blob/999cddd58d30469f3ee85278985313fdf528323d/django/core/cache/__init__.py#L116-L121

In other words, I don't think Django's caching framework needs to change... for most of it besides those aforementioned lines. That's all I've got for now (midterms are tomorrow). Let me know if there are any critical failures.

Cheers,
Andrew

Adam Johnson

unread,
Oct 9, 2020, 2:08:01 PM10/9/20
to django-d...@googlegroups.com
Hi Andrew

THank you for making this. This looks like a great start.

I made a small PR regarding the cache.close method.

Since signals are synchronous (for now?) I think you do need the wrapper.

What about implementations of the sync methods? You could make them raise an exception (async only) or use async_to_sync.

Good luck with your exams,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9eabc712-a33a-4d93-a326-3a683d11c62bn%40googlegroups.com.


--
Adam
Reply all
Reply to author
Forward
0 new messages