1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index 2ea4a63e5a..d0767c269d 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -176,13 +176,13 @@ class LruCache(Generic[KT, VT]):
def evict():
ten_minutes_ago = int(reactor.seconds()) - 10 * 60
+ todelete = list_root.prev_node
while (
cache_len() > self.max_size
- or 0 < list_root.prev_node.allocated_ts < ten_minutes_ago + 60
+ or 0 < todelete.allocated_ts < ten_minutes_ago + 60
):
- todelete = list_root.prev_node
-
if 0 < todelete.allocated_ts < ten_minutes_ago:
+ todelete = list_root.prev_node
continue
todelete = list_root.prev_node
@@ -194,6 +194,8 @@ class LruCache(Generic[KT, VT]):
if metrics:
metrics.inc_evictions(evicted_len)
+ todelete = list_root.prev_node
+
def synchronized(f: FT) -> FT:
@wraps(f)
def inner(*args, **kwargs):
|