summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-06 13:35:03 +0100
committerErik Johnston <erik@matrix.org>2015-08-06 13:35:03 +0100
commit953dbd28a726dc47829e5d774c78288ed7c91e72 (patch)
tree6d4dbf2656816e1506f16c272fd4d8c5357fea2e /synapse/storage
parentAdd support for using keyword arguments with cached functions (diff)
parentUp the cache size for 'get_joined_hosts_for_room' and 'get_users_in_room' (diff)
downloadsynapse-953dbd28a726dc47829e5d774c78288ed7c91e72.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/cached_keyword_args
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/_base.py6
-rw-r--r--synapse/storage/roommember.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index f1265541ba..f74b81b7a2 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -58,7 +58,7 @@ cache_counter = metrics.register_cache(
 
 class Cache(object):
 
-    def __init__(self, name, max_entries=1000, keylen=1, lru=False):
+    def __init__(self, name, max_entries=1000, keylen=1, lru=True):
         if lru:
             self.cache = LruCache(max_size=max_entries)
             self.max_entries = None
@@ -142,7 +142,7 @@ class CacheDescriptor(object):
     which can be used to insert values into the cache specifically, without
     calling the calculation function.
     """
-    def __init__(self, orig, max_entries=1000, num_args=1, lru=False,
+    def __init__(self, orig, max_entries=1000, num_args=1, lru=True,
                  inlineCallbacks=False):
         self.orig = orig
 
@@ -210,7 +210,7 @@ class CacheDescriptor(object):
         return wrapped
 
 
-def cached(max_entries=1000, num_args=1, lru=False):
+def cached(max_entries=1000, num_args=1, lru=True):
     return lambda orig: CacheDescriptor(
         orig,
         max_entries=max_entries,
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 4db07f6fb4..55dd3f6cfb 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -78,7 +78,7 @@ class RoomMemberStore(SQLBaseStore):
             lambda events: events[0] if events else None
         )
 
-    @cached()
+    @cached(max_entries=5000)
     def get_users_in_room(self, room_id):
         def f(txn):
 
@@ -154,7 +154,7 @@ class RoomMemberStore(SQLBaseStore):
             RoomsForUser(**r) for r in self.cursor_to_dict(txn)
         ]
 
-    @cached()
+    @cached(max_entries=5000)
     def get_joined_hosts_for_room(self, room_id):
         return self.runInteraction(
             "get_joined_hosts_for_room",