summary refs log tree commit diff
path: root/synapse/util/caches/descriptors.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-01 12:56:39 +0000
committerErik Johnston <erik@matrix.org>2016-03-01 12:56:39 +0000
commit910fc0f28f82ca7c719b5bbe98f4d3c2d0d76abf (patch)
tree7f3562e80c4557189de140e1075d7597b39fc148 /synapse/util/caches/descriptors.py
parentMerge pull request #611 from matrix-org/erikj/expiring_cache_size (diff)
downloadsynapse-910fc0f28f82ca7c719b5bbe98f4d3c2d0d76abf.tar.xz
Add enviroment variable SYNAPSE_CACHE_FACTOR, default it to 0.1
Diffstat (limited to 'synapse/util/caches/descriptors.py')
-rw-r--r--synapse/util/caches/descriptors.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py
index 277854ccbc..2b51ad6d04 100644
--- a/synapse/util/caches/descriptors.py
+++ b/synapse/util/caches/descriptors.py
@@ -28,6 +28,7 @@ from twisted.internet import defer
 
 from collections import OrderedDict
 
+import os
 import functools
 import inspect
 import threading
@@ -38,9 +39,14 @@ logger = logging.getLogger(__name__)
 _CacheSentinel = object()
 
 
+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(