summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-12-16 08:53:28 -0500
committerGitHub <noreply@github.com>2022-12-16 08:53:28 -0500
commit3aeca2588b79111a48a6083c88efc4d68a2cea19 (patch)
treecd1850aba9ddcb05a9b357541a5c20b6ca617b99 /synapse
parentImprove type annotations for the helper methods on a `CachedFunction`. (#14685) (diff)
downloadsynapse-3aeca2588b79111a48a6083c88efc4d68a2cea19.tar.xz
Add missing type hints to tests.config. (#14681)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/config/cache.py4
-rw-r--r--synapse/util/caches/lrucache.py9
2 files changed, 4 insertions, 9 deletions
diff --git a/synapse/config/cache.py b/synapse/config/cache.py
index eb4194a5a9..015b2a138e 100644
--- a/synapse/config/cache.py
+++ b/synapse/config/cache.py
@@ -16,7 +16,7 @@ import logging
 import os
 import re
 import threading
-from typing import Any, Callable, Dict, Optional
+from typing import Any, Callable, Dict, Mapping, Optional
 
 import attr
 
@@ -94,7 +94,7 @@ def add_resizable_cache(
 
 class CacheConfig(Config):
     section = "caches"
-    _environ = os.environ
+    _environ: Mapping[str, str] = os.environ
 
     event_cache_size: int
     cache_factors: Dict[str, float]
diff --git a/synapse/util/caches/lrucache.py b/synapse/util/caches/lrucache.py
index dcf0eac3bf..452d5d04c1 100644
--- a/synapse/util/caches/lrucache.py
+++ b/synapse/util/caches/lrucache.py
@@ -788,26 +788,21 @@ class LruCache(Generic[KT, VT]):
     def __contains__(self, key: KT) -> bool:
         return self.contains(key)
 
-    def set_cache_factor(self, factor: float) -> bool:
+    def set_cache_factor(self, factor: float) -> None:
         """
         Set the cache factor for this individual cache.
 
         This will trigger a resize if it changes, which may require evicting
         items from the cache.
-
-        Returns:
-            Whether the cache changed size or not.
         """
         if not self.apply_cache_factor_from_config:
-            return False
+            return
 
         new_size = int(self._original_max_size * factor)
         if new_size != self.max_size:
             self.max_size = new_size
             if self._on_resize:
                 self._on_resize()
-            return True
-        return False
 
     def __del__(self) -> None:
         # We're about to be deleted, so we make sure to clear up all the nodes