mirror of
https://github.com/django/django.git
synced 2025-11-01 12:25:37 +00:00
Fixed #30759 -- Made cache.delete() return whether it succeeded.
Thanks Simon Charette for the review.
This commit is contained in:
parent
6e99585c19
commit
efc3e32d6d
9 changed files with 43 additions and 15 deletions
|
|
@ -118,6 +118,9 @@ Cache
|
|||
field names in the ``no-cache`` directive for the ``Cache-Control`` header,
|
||||
according to :rfc:`7234#section-5.2.2.2`.
|
||||
|
||||
* :meth:`~django.core.caches.cache.delete` now returns ``True`` if the key was
|
||||
successfully deleted, ``False`` otherwise.
|
||||
|
||||
CSRF
|
||||
~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -724,6 +724,7 @@ a cached item, for example:
|
|||
# cache key for {% cache 500 sidebar username %}
|
||||
>>> key = make_template_fragment_key('sidebar', [username])
|
||||
>>> cache.delete(key) # invalidates cached template fragment
|
||||
True
|
||||
|
||||
.. _low-level-cache-api:
|
||||
|
||||
|
|
@ -884,6 +885,14 @@ You can delete keys explicitly with ``delete()`` to clear the cache for a
|
|||
particular object::
|
||||
|
||||
>>> cache.delete('a')
|
||||
True
|
||||
|
||||
``delete()`` returns ``True`` if the key was successfully deleted, ``False``
|
||||
otherwise.
|
||||
|
||||
.. versionchanged:: 3.1
|
||||
|
||||
The boolean return value was added.
|
||||
|
||||
.. method:: cache.delete_many(keys, version=None)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue