Skip to content

Commit

Permalink
Handle missing touch method, for django < 2.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdyer committed Jan 18, 2019
1 parent 9473f68 commit 7f5f56c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion completion_aggregator/cachegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 7f5f56c

Please sign in to comment.