From e2013b260a8f689eee280d00b96a9507895ec236 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Mon, 17 Aug 2020 00:18:51 +0100 Subject: [PATCH] Refs #29887, #27480 -- Moved touch() to BaseMemcachedCache. --- django/core/cache/backends/memcached.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py index 4b0f8f6b8e..245366c799 100644 --- a/django/core/cache/backends/memcached.py +++ b/django/core/cache/backends/memcached.py @@ -79,6 +79,10 @@ class BaseMemcachedCache(BaseCache): # make sure the key doesn't keep its old value in case of failure to set (memcached's 1MB limit) self._cache.delete(key) + def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None): + key = self.make_key(key, version=version) + return bool(self._cache.touch(key, self.get_backend_timeout(timeout))) + def delete(self, key, version=None): key = self.make_key(key, version=version) self.validate_key(key) @@ -167,10 +171,6 @@ class MemcachedCache(BaseMemcachedCache): self._client = self._lib.Client(self._servers, **client_kwargs) return self._client - def touch(self, key, timeout=DEFAULT_TIMEOUT, version=None): - key = self.make_key(key, version=version) - return self._cache.touch(key, self.get_backend_timeout(timeout)) != 0 - def get(self, key, default=None, version=None): key = self.make_key(key, version=version) val = self._cache.get(key)