diff options
| author | Nicolas NoƩ <nicolas@niconoe.org> | 2018-04-27 23:48:35 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-04-27 17:48:35 -0400 |
| commit | 3246ad106517e61437f80e8ef3c9d216754039e7 (patch) | |
| tree | 29fba867b071b61c9cfcc1d33d4662c91f1e40fa /docs/topics | |
| parent | 8e960c5aba70d834f54b0bc66f2fb5e922a35b41 (diff) | |
Fixed #27480 -- Added cache.touch().
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/cache.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index 8c5630f3e2..3ca3a08a4a 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -734,6 +734,7 @@ a cached item, for example: >>> key = make_template_fragment_key('sidebar', [username]) >>> cache.delete(key) # invalidates cached template fragment +.. _low-level-cache-api: The low-level cache API ======================= @@ -891,6 +892,22 @@ from the cache, not just the keys set by your application. :: >>> cache.clear() +``cache.touch()`` sets a new expiration for a key. For example, to update a key +to expire 10 seconds from now:: + + >>> cache.touch('a', 10) + True + +Like other methods, the ``timeout`` argument is optional and defaults to the +``TIMEOUT`` option of the appropriate backend in the :setting:`CACHES` setting. + +``touch()`` returns ``True`` if the key was successfully touched, ``False`` +otherwise. + +.. versionchanged:: 2.1 + + The ``cache.touch()`` method was added. + You can also increment or decrement a key that already exists using the ``incr()`` or ``decr()`` methods, respectively. By default, the existing cache value will be incremented or decremented by 1. Other increment/decrement values |
