summary refs log tree commit diff
path: root/synapse/util/caches/lrucache.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2022-02-15 14:31:04 +0000
committerGitHub <noreply@github.com>2022-02-15 14:31:04 +0000
commit0dbbe33a65c17cdb1ad41d6109b5629029dce886 (patch)
tree1813f0acb252c5c2a383db79e1842e3d4a738178 /synapse/util/caches/lrucache.py
parentFix incorrect `get_rooms_for_user` for remote user (#11999) (diff)
downloadsynapse-0dbbe33a65c17cdb1ad41d6109b5629029dce886.tar.xz
Track cache invalidations (#12000)
Currently we only track evictions due to size or time constraints.
Diffstat (limited to 'synapse/util/caches/lrucache.py')
-rw-r--r--synapse/util/caches/lrucache.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index 7548b38548..45ff0de638 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -560,8 +560,10 @@ class LruCache(Generic[KT, VT]):
         def cache_pop(key: KT, default: Optional[T] = None) -> Union[None, T, VT]:
             node = cache.get(key, None)
             if node:
-                delete_node(node)
+                evicted_len = delete_node(node)
                 cache.pop(node.key, None)
+                if metrics:
+                    metrics.inc_evictions(EvictionReason.invalidation, evicted_len)
                 return node.value
             else:
                 return default