diff --git a/synapse/config/cache.py b/synapse/config/cache.py index bd9c5e5aaa..29338739b8 100644 --- a/synapse/config/cache.py +++ b/synapse/config/cache.py @@ -14,7 +14,7 @@ # limitations under the License. import os -from typing import Dict +from typing import Callable, Dict, Optional, Union from ._base import Config, ConfigError @@ -22,7 +22,7 @@ _CACHES = {} _CACHE_PREFIX = "SYNAPSE_CACHE_FACTOR" # Wrap all global vars into a single object to eliminate `global` calls -CACHE_PROPERTIES = { +CACHE_PROPERTIES: Dict[str, Union[str, float, Optional[Callable[[], None]]]] = { "prefix": _CACHE_PREFIX, "default_size_factor": float(os.environ.get(_CACHE_PREFIX, 0.5)), # Callback to ensure that all caches are the correct size, registered when the @@ -33,6 +33,7 @@ CACHE_PROPERTIES = { def add_resizable_cache(cache_name, cache_resize_callback): _CACHES[cache_name.lower()] = cache_resize_callback + if CACHE_PROPERTIES["ensure_correct_cache_sizing"]: CACHE_PROPERTIES["ensure_correct_cache_sizing"]()