summary refs log tree commit diff
path: root/synapse/util/caches/dictionary_cache.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-06-03 11:57:29 +0100
committerErik Johnston <erik@matrix.org>2016-06-03 11:57:29 +0100
commit43b7f371f5f1e696a8d4b3ccce1861b6c5473bcb (patch)
tree0903f9e9e9a2c7464bba93ba862b3ca1bf13a13f /synapse/util/caches/dictionary_cache.py
parentMerge pull request #829 from matrix-org/erikj/poke_notifier (diff)
parentChange CacheMetrics to be quicker (diff)
downloadsynapse-43b7f371f5f1e696a8d4b3ccce1861b6c5473bcb.tar.xz
Merge pull request #830 from matrix-org/erikj/metrics_perf
Change CacheMetrics to be quicker
Diffstat (limited to 'synapse/util/caches/dictionary_cache.py')
-rw-r--r--synapse/util/caches/dictionary_cache.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/util/caches/dictionary_cache.py b/synapse/util/caches/dictionary_cache.py
index f92d80542b..b0ca1bb79d 100644
--- a/synapse/util/caches/dictionary_cache.py
+++ b/synapse/util/caches/dictionary_cache.py
@@ -15,7 +15,7 @@
 
 from synapse.util.caches.lrucache import LruCache
 from collections import namedtuple
-from . import caches_by_name, cache_counter
+from . import register_cache
 import threading
 import logging
 
@@ -43,7 +43,7 @@ class DictionaryCache(object):
             __slots__ = []
 
         self.sentinel = Sentinel()
-        caches_by_name[name] = self.cache
+        self.metrics = register_cache(name, self.cache)
 
     def check_thread(self):
         expected_thread = self.thread
@@ -58,7 +58,7 @@ class DictionaryCache(object):
     def get(self, key, dict_keys=None):
         entry = self.cache.get(key, self.sentinel)
         if entry is not self.sentinel:
-            cache_counter.inc_hits(self.name)
+            self.metrics.inc_hits()
 
             if dict_keys is None:
                 return DictionaryEntry(entry.full, dict(entry.value))
@@ -69,7 +69,7 @@ class DictionaryCache(object):
                     if k in entry.value
                 })
 
-        cache_counter.inc_misses(self.name)
+        self.metrics.inc_misses()
         return DictionaryEntry(False, {})
 
     def invalidate(self, key):