diff options
| author | Andrew-Chen-Wang <acwangpython@gmail.com> | 2020-10-16 10:16:55 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-07 20:14:25 +0200 |
| commit | 301a85a12f3c2c9427c7ff581fd4683bab1f29f6 (patch) | |
| tree | 65dd48af81539258eed38b86d144107f33f74a74 /docs | |
| parent | 42dfa97e191d8f7ffdc0b5d9502949ef3b8ef356 (diff) | |
Fixed #32076 -- Added async methods to BaseCache.
This also makes DummyCache async-compatible.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/4.0.txt | 8 | ||||
| -rw-r--r-- | docs/topics/cache.txt | 31 |
2 files changed, 38 insertions, 1 deletions
diff --git a/docs/releases/4.0.txt b/docs/releases/4.0.txt index e64f6633ef..88b3c8ac37 100644 --- a/docs/releases/4.0.txt +++ b/docs/releases/4.0.txt @@ -187,7 +187,13 @@ Minor features Cache ~~~~~ -* ... +* The new async API for ``django.core.cache.backends.base.BaseCache`` begins + the process of making cache backends async-compatible. The new async methods + all have ``a`` prefixed names, e.g. ``aadd()``, ``aget()``, ``aset()``, + ``aget_or_set()``, or ``adelete_many()``. + + Going forward, the ``a`` prefix will be used for async variants of methods + generally. CSRF ~~~~ diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index 27414df344..0f25260672 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -808,6 +808,8 @@ Accessing the cache This object is equivalent to ``caches['default']``. +.. _cache-basic-interface: + Basic usage ----------- @@ -997,6 +999,16 @@ the cache backend. For caches that don't implement ``close`` methods it is a no-op. +.. note:: + + The async variants of base methods are prefixed with ``a``, e.g. + ``cache.aadd()`` or ``cache.adelete_many()``. See `Asynchronous support`_ + for more details. + +.. versionchanged:: 4.0 + + The async variants of methods were added to the ``BaseCache``. + .. _cache_key_prefixing: Cache key prefixing @@ -1123,6 +1135,25 @@ instance, to do this for the ``locmem`` backend, put this code in a module:: ...and use the dotted Python path to this class in the :setting:`BACKEND <CACHES-BACKEND>` portion of your :setting:`CACHES` setting. +.. _asynchronous_support: + +Asynchronous support +==================== + +.. versionadded:: 4.0 + +Django has developing support for asynchronous cache backends, but does not +yet support asynchronous caching. It will be coming in a future release. + +``django.core.cache.backends.base.BaseCache`` has async variants of :ref:`all +base methods <cache-basic-interface>`. By convention, the asynchronous versions +of all methods are prefixed with ``a``. By default, the arguments for both +variants are the same:: + + >>> await cache.aset('num', 1) + >>> await cache.ahas_key('num') + True + .. _downstream-caches: Downstream caches |
