summary refs log tree commit diff
path: root/synapse/util/caches/__init__.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2018-06-04 17:19:33 +0100
committerGitHub <noreply@github.com>2018-06-04 17:19:33 +0100
commit28b0490dfdce04c584d36ae409abc42b6ac419b2 (patch)
tree4f42fe1eaf4a2214d8e64721b446930e91ca6863 /synapse/util/caches/__init__.py
parentFix replication metrics (diff)
parentAdd hacky cache factor override system (diff)
downloadsynapse-28b0490dfdce04c584d36ae409abc42b6ac419b2.tar.xz
Merge pull request #3334 from matrix-org/rav/cache_factor_override
Cache factor override system for specific caches
Diffstat (limited to 'synapse/util/caches/__init__.py')
-rw-r--r--synapse/util/caches/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/synapse/util/caches/__init__.py b/synapse/util/caches/__init__.py

index 183faf75a1..900575eb3c 100644 --- a/synapse/util/caches/__init__.py +++ b/synapse/util/caches/__init__.py
@@ -22,6 +22,16 @@ import six CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5)) + +def get_cache_factor_for(cache_name): + env_var = "SYNAPSE_CACHE_FACTOR_" + cache_name.upper() + factor = os.environ.get(env_var) + if factor: + return float(factor) + + return CACHE_SIZE_FACTOR + + caches_by_name = {} collectors_by_name = {}