summary refs log tree commit diff
path: root/synapse/util/caches/expiringcache.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-02-01 17:57:51 +0000
committerRichard van der Hoff <richard@matrix.org>2018-02-05 15:34:01 +0000
commitbc496df192fa20dee933590d5f21a3425388c0d7 (patch)
treefefd2b856942185a6fe114cff46ce3228872d06e /synapse/util/caches/expiringcache.py
parentMerge pull request #2837 from matrix-org/rav/fix_quarantine_media (diff)
downloadsynapse-bc496df192fa20dee933590d5f21a3425388c0d7.tar.xz
report metrics on number of cache evictions
Diffstat (limited to 'synapse/util/caches/expiringcache.py')
-rw-r--r--synapse/util/caches/expiringcache.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/util/caches/expiringcache.py b/synapse/util/caches/expiringcache.py
index 6ad53a6390..0aa103eecb 100644
--- a/synapse/util/caches/expiringcache.py
+++ b/synapse/util/caches/expiringcache.py
@@ -79,7 +79,11 @@ class ExpiringCache(object):
         while self._max_len and len(self) > self._max_len:
             _key, value = self._cache.popitem(last=False)
             if self.iterable:
-                self._size_estimate -= len(value.value)
+                removed_len = len(value.value)
+                self.metrics.inc_evictions(removed_len)
+                self._size_estimate -= removed_len
+            else:
+                self.metrics.inc_evictions()
 
     def __getitem__(self, key):
         try: