summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r--synapse/storage/roommember.py28
1 files changed, 1 insertions, 27 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 569bd55d0f..b8fcc1927e 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -17,7 +17,7 @@ from twisted.internet import defer
 
 from collections import namedtuple
 
-from ._base import SQLBaseStore
+from ._base import SQLBaseStore, cached
 
 from synapse.api.constants import Membership
 from synapse.types import UserID
@@ -33,32 +33,6 @@ RoomsForUser = namedtuple(
 )
 
 
-# TODO(paul):
-#  * Move this somewhere higher-level, shared;
-#  * more generic key management
-#  * export monitoring stats
-#  * maximum size; just evict things at random, or consider LRU?
-def cached(orig):
-    cache = {}
-
-    @defer.inlineCallbacks
-    def wrapped(self, key):
-        if key in cache:
-            defer.returnValue(cache[key])
-
-        ret = yield orig(self, key)
-
-        cache[key] = ret;
-        defer.returnValue(ret)
-
-    def invalidate(key):
-        if key in cache:
-            del cache[key]
-
-    wrapped.invalidate = invalidate
-    return wrapped
-
-
 class RoomMemberStore(SQLBaseStore):
 
     def __init__(self, *args, **kw):