mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:06:07 -04:00
Add a five minute cache to get_destination_retry_timings
Hopefully helps with #3931
This commit is contained in:
parent
79eded1ae4
commit
fdd1a62e8d
2 changed files with 35 additions and 1 deletions
|
@ -24,6 +24,9 @@ from synapse.util.caches import register_cache
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
SENTINEL = object()
|
||||
|
||||
|
||||
class ExpiringCache(object):
|
||||
def __init__(self, cache_name, clock, max_len=0, expiry_ms=0,
|
||||
reset_expiry_on_get=False, iterable=False):
|
||||
|
@ -102,6 +105,16 @@ class ExpiringCache(object):
|
|||
|
||||
return entry.value
|
||||
|
||||
def pop(self, key, default=None):
|
||||
value = self._cache.pop(key, SENTINEL)
|
||||
if value is SENTINEL:
|
||||
return default
|
||||
|
||||
if self.iterable:
|
||||
self._size_estimate -= len(value.value)
|
||||
|
||||
return value
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self._cache
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue