summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-10 10:39:22 +0100
committerErik Johnston <erik@matrix.org>2015-08-10 10:39:22 +0100
commite0b6e49466cc8499f3d4890fbb4c532f1d38bef5 (patch)
treeb68ad308689e08b4c5e5ce24b5fe58a0dfdaa06b
parentDo bounds check (diff)
parentRename keyargs to args in Cache (diff)
downloadsynapse-e0b6e49466cc8499f3d4890fbb4c532f1d38bef5.tar.xz
Merge branch 'erikj/cache_varargs_interface' of github.com:matrix-org/synapse into erikj/dictionary_cache
-rw-r--r--synapse/storage/_base.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index a49dbb2ef5..a7590145ac 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -88,8 +88,8 @@ class Cache(object):
                     "Cache objects can only be accessed from the main thread"
                 )
 
-    def get(self, keyargs, default=_CacheSentinel):
-        val = self.cache.get(keyargs, _CacheSentinel)
+    def get(self, key, default=_CacheSentinel):
+        val = self.cache.get(key, _CacheSentinel)
         if val is not _CacheSentinel:
             cache_counter.inc_hits(self.name)
             return val
@@ -101,29 +101,29 @@ class Cache(object):
         else:
             return default
 
-    def update(self, sequence, keyargs, value):
+    def update(self, sequence, key, value):
         self.check_thread()
         if self.sequence == sequence:
             # Only update the cache if the caches sequence number matches the
             # number that the cache had before the SELECT was started (SYN-369)
-            self.prefill(keyargs, value)
+            self.prefill(key, value)
 
-    def prefill(self, keyargs, value):
+    def prefill(self, key, value):
         if self.max_entries is not None:
             while len(self.cache) >= self.max_entries:
                 self.cache.popitem(last=False)
 
-        self.cache[keyargs] = value
+        self.cache[key] = value
 
-    def invalidate(self, keyargs):
+    def invalidate(self, key):
         self.check_thread()
-        if not isinstance(keyargs, tuple):
+        if not isinstance(key, tuple):
             raise ValueError("keyargs must be a tuple.")
 
         # Increment the sequence number so that any SELECT statements that
         # raced with the INSERT don't update the cache (SYN-369)
         self.sequence += 1
-        self.cache.pop(keyargs, None)
+        self.cache.pop(key, None)
 
     def invalidate_all(self):
         self.check_thread()