diff options
author | Erik Johnston <erik@matrix.org> | 2016-03-02 14:36:10 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-03-02 14:36:10 +0000 |
commit | 2a78dac60dc5d7ba7050386ba864f83f8d19e8e6 (patch) | |
tree | 5acc2246661fece680929dacbe73522b336cdce8 /synapse/util/caches/descriptors.py | |
parent | Merge pull request #489 from matrix-org/markjh/replication (diff) | |
parent | Set SYNAPSE_CACHE_FACTOR=1 in jenkins (diff) | |
download | synapse-2a78dac60dc5d7ba7050386ba864f83f8d19e8e6.tar.xz |
Merge pull request #612 from matrix-org/erikj/cache_size
Add environment variable SYNAPSE_CACHE_FACTOR, default it to 0.1
Diffstat (limited to 'synapse/util/caches/descriptors.py')
-rw-r--r-- | synapse/util/caches/descriptors.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/util/caches/descriptors.py b/synapse/util/caches/descriptors.py index 277854ccbc..35544b19fd 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,6 +39,9 @@ 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): @@ -140,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: |