Skip to content
Snippets Groups Projects
Commit 3545e17f authored by Erik Johnston's avatar Erik Johnston
Browse files

Add setdefault key to ExpiringCache

parent 45d173a5
No related branches found
No related tags found
No related merge requests found
...@@ -100,6 +100,13 @@ class ExpiringCache(object): ...@@ -100,6 +100,13 @@ class ExpiringCache(object):
except KeyError: except KeyError:
return default return default
def setdefault(self, key, value):
try:
return self[key]
except KeyError:
self[key] = value
return value
def _prune_cache(self): def _prune_cache(self):
if not self._expiry_ms: if not self._expiry_ms:
# zero expiry time means don't expire. This should never get called # zero expiry time means don't expire. This should never get called
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment