summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-01 13:21:46 +0000
committerErik Johnston <erik@matrix.org>2016-03-01 13:21:46 +0000
commitce2cdced6136e81e182242c11c50e7b1c8a5a622 (patch)
treea0feee0431c366ba5ade44f200b9160483d7e49a /synapse/util/caches
parentAdd enviroment variable SYNAPSE_CACHE_FACTOR, default it to 0.1 (diff)
downloadsynapse-ce2cdced6136e81e182242c11c50e7b1c8a5a622.tar.xz
Move cache size fiddling to descriptors only. Fix tests
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/descriptors.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index 2b51ad6d04..35544b19fd 100644
--- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py
@@ -45,8 +45,6 @@ CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.1))
 class Cache(object):
 
     def __init__(self, name, max_entries=1000, keylen=1, lru=True, tree=False):
-        max_entries = int(max_entries * CACHE_SIZE_FACTOR)
-
         if lru:
             cache_type = TreeCache if tree else dict
             self.cache = LruCache(
@@ -146,6 +144,8 @@ class CacheDescriptor(object):
     """
     def __init__(self, orig, max_entries=1000, num_args=1, lru=True, tree=False,
                  inlineCallbacks=False):
+        max_entries = int(max_entries * CACHE_SIZE_FACTOR)
+
         self.orig = orig
 
         if inlineCallbacks: