From 7f5f56c231ac089f2e82626206355d3f65621db8 Mon Sep 17 00:00:00 2001 From: "J. Cliff Dyer" Date: Fri, 18 Jan 2019 10:31:52 -0500 Subject: [PATCH] Handle missing touch method, for django < 2.1. --- completion_aggregator/cachegroup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/completion_aggregator/cachegroup.py b/completion_aggregator/cachegroup.py index da34d6c3..067d8492 100644 --- a/completion_aggregator/cachegroup.py +++ b/completion_aggregator/cachegroup.py @@ -56,8 +56,14 @@ def set(self, group, key, value, timeout): def touch(self, key, timeout): """ Update the timeout for a given key in the cache. + + Returns True if the cache key was updated. + + This functionality is available in Django 2.1 and above. """ - return cache.touch(key, timeout=timeout) + if hasattr(cache, 'touch'): + return cache.touch(key, timeout=timeout) + return False def delete(self, key): """