mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-16 15:01:23 +01:00
Add setdefault key to ExpiringCache
This commit is contained in:
parent
45d173a59a
commit
3545e17f43
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue