pull/6391/head
Andrew Morgan 2020-04-03 18:09:55 +01:00
parent 14fbf27709
commit cc1dd98362
1 changed files with 4 additions and 3 deletions

View File

@ -25,7 +25,6 @@ _CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR"
CACHE_PROPERTIES = { CACHE_PROPERTIES = {
"prefix": _CACHE_PREFIX, "prefix": _CACHE_PREFIX,
"default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)), "default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)),
# Callback to ensure that all caches are the correct size, registered when the # Callback to ensure that all caches are the correct size, registered when the
# configuration has been loaded. # configuration has been loaded.
"ensure_correct_cache_sizing": None, "ensure_correct_cache_sizing": None,
@ -48,7 +47,9 @@ class CacheConfig(Config):
Used for tests. Used for tests.
""" """
CACHE_PROPERTIES["default_size_factor"] = float(os.environ.get(_CACHE_PREFIX, 0.5)) CACHE_PROPERTIES["default_size_factor"] = float(
os.environ.get(_CACHE_PREFIX, 0.5)
)
CACHE_PROPERTIES["ensure_correct_cache_sizing"] = None CACHE_PROPERTIES["ensure_correct_cache_sizing"] = None
_CACHES.clear() _CACHES.clear()
@ -86,7 +87,7 @@ class CacheConfig(Config):
# Load cache factors from the environment, but override them with the # Load cache factors from the environment, but override them with the
# ones in the config file if they exist # ones in the config file if they exist
individual_factors = { individual_factors = {
key[len(CACHE_PROPERTIES["prefix"]) + 1:].lower(): float(val) key[len(CACHE_PROPERTIES["prefix"]) + 1 :].lower(): float(val)
for key, val in self._environ.items() for key, val in self._environ.items()
if key.startswith(CACHE_PROPERTIES["prefix"] + "_") if key.startswith(CACHE_PROPERTIES["prefix"] + "_")
} }