summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-01-16 13:48:04 +0000
committerErik Johnston <erik@matrix.org>2017-01-16 14:57:23 +0000
commit46aebbbcbf94eb78ae45d3bb3bf3ffeabb44dd4f (patch)
treeb779fe38389497fbb1cce9f8fdfed9cebe0f47eb /synapse/state.py
parentIncrease cache size limit (diff)
downloadsynapse-46aebbbcbf94eb78ae45d3bb3bf3ffeabb44dd4f.tar.xz
Add support for 'iterable' to ExpiringCache
Diffstat (limited to 'synapse/state.py')
-rw-r--r--synapse/state.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/state.py b/synapse/state.py
index b9d5627a82..461e82acdf 100644
--- a/synapse/state.py
+++ b/synapse/state.py
@@ -41,7 +41,7 @@ KeyStateTuple = namedtuple("KeyStateTuple", ("context", "type", "state_key"))
 CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.1))
 
 
-SIZE_OF_CACHE = int(1000 * CACHE_SIZE_FACTOR)
+SIZE_OF_CACHE = int(10000 * CACHE_SIZE_FACTOR)
 EVICTION_TIMEOUT_SECONDS = 60 * 60
 
 
@@ -77,6 +77,9 @@ class _StateCacheEntry(object):
         else:
             self.state_id = _gen_state_id()
 
+    def __len__(self):
+        return len(self.state)
+
 
 class StateHandler(object):
     """ Responsible for doing state conflict resolution.
@@ -99,6 +102,7 @@ class StateHandler(object):
             clock=self.clock,
             max_len=SIZE_OF_CACHE,
             expiry_ms=EVICTION_TIMEOUT_SECONDS * 1000,
+            iterable=True,
             reset_expiry_on_get=True,
         )