summary refs log tree commit diff
path: root/synapse/config/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/config/cache.py')
-rw-r--r--synapse/config/cache.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/synapse/config/cache.py b/synapse/config/cache.py
index d9d85f98e1..f054455534 100644
--- a/synapse/config/cache.py
+++ b/synapse/config/cache.py
@@ -1,4 +1,4 @@
-# Copyright 2019-2021 Matrix.org Foundation C.I.C.
+# Copyright 2019 Matrix.org Foundation C.I.C.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@ import re
 import threading
 from typing import Callable, Dict, Optional
 
-import attr
-
 from synapse.python_dependencies import DependencyException, check_requirements
 
 from ._base import Config, ConfigError
@@ -36,13 +34,13 @@ _DEFAULT_FACTOR_SIZE = 0.5
 _DEFAULT_EVENT_CACHE_SIZE = "10K"
 
 
-@attr.s(slots=True, auto_attribs=True)
 class CacheProperties:
-    # The default factor size for all caches
-    default_factor_size: float = float(
-        os.environ.get(_CACHE_PREFIX, _DEFAULT_FACTOR_SIZE)
-    )
-    resize_all_caches_func: Optional[Callable[[], None]] = None
+    def __init__(self):
+        # The default factor size for all caches
+        self.default_factor_size = float(
+            os.environ.get(_CACHE_PREFIX, _DEFAULT_FACTOR_SIZE)
+        )
+        self.resize_all_caches_func = None
 
 
 properties = CacheProperties()
@@ -64,7 +62,7 @@ def _canonicalise_cache_name(cache_name: str) -> str:
 
 def add_resizable_cache(
     cache_name: str, cache_resize_callback: Callable[[float], None]
-) -> None:
+):
     """Register a cache that's size can dynamically change
 
     Args:
@@ -93,7 +91,7 @@ class CacheConfig(Config):
     _environ = os.environ
 
     @staticmethod
-    def reset() -> None:
+    def reset():
         """Resets the caches to their defaults. Used for tests."""
         properties.default_factor_size = float(
             os.environ.get(_CACHE_PREFIX, _DEFAULT_FACTOR_SIZE)
@@ -102,7 +100,7 @@ class CacheConfig(Config):
         with _CACHES_LOCK:
             _CACHES.clear()
 
-    def generate_config_section(self, **kwargs) -> str:
+    def generate_config_section(self, **kwargs):
         return """\
         ## Caching ##
 
@@ -164,7 +162,7 @@ class CacheConfig(Config):
           #sync_response_cache_duration: 2m
         """
 
-    def read_config(self, config, **kwargs) -> None:
+    def read_config(self, config, **kwargs):
         self.event_cache_size = self.parse_size(
             config.get("event_cache_size", _DEFAULT_EVENT_CACHE_SIZE)
         )
@@ -234,7 +232,7 @@ class CacheConfig(Config):
         # needing an instance of Config
         properties.resize_all_caches_func = self.resize_all_caches
 
-    def resize_all_caches(self) -> None:
+    def resize_all_caches(self):
         """Ensure all cache sizes are up to date
 
         For each cache, run the mapped callback function with either