From efc3e32d6d7fb9bb41be73b80c8607b653c1fbd6 Mon Sep 17 00:00:00 2001 From: daniel a rios Date: Tue, 8 Oct 2019 11:02:40 +0200 Subject: Fixed #30759 -- Made cache.delete() return whether it succeeded. Thanks Simon Charette for the review. --- docs/releases/3.1.txt | 3 +++ docs/topics/cache.txt | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'docs') diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt index de114e7098..f725e4e056 100644 --- a/docs/releases/3.1.txt +++ b/docs/releases/3.1.txt @@ -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 ~~~~ diff --git a/docs/topics/cache.txt b/docs/topics/cache.txt index ce030d4221..a038183d0d 100644 --- a/docs/topics/cache.txt +++ b/docs/topics/cache.txt @@ -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) -- cgit v1.3