summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-01-17 11:51:09 +0000
committerGitHub <noreply@github.com>2017-01-17 11:51:09 +0000
commitd11d7cdf875e524ce217ff3b091a07fb1c3b99ae (patch)
tree5f88266e2cc5c5ea5afe564d4488f65af3d227d1 /synapse/state.py
parentMerge pull request #1810 from matrix-org/erikj/state_auth_splitout_split (diff)
parentTidy up test (diff)
downloadsynapse-d11d7cdf875e524ce217ff3b091a07fb1c3b99ae.tar.xz
Merge pull request #1815 from matrix-org/erikj/iter_cache_size
Optionally measure size of cache by sum of length of values
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..66e1a685e8 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(100000 * 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,
         )