summary refs log tree commit diff
path: root/synapse/util/caches
diff options
context:
space:
mode:
authorJonathan de Jong <jonathan@automatia.nl>2021-03-08 20:00:07 +0100
committerGitHub <noreply@github.com>2021-03-08 14:00:07 -0500
commitd6196efafcc312472464c882ab630bc3fbf7bd37 (patch)
tree661bc8b15d55f2f04776a2ea23e773e1506d6ee7 /synapse/util/caches
parentWarn that /register will soon require a type when called with an access token... (diff)
downloadsynapse-d6196efafcc312472464c882ab630bc3fbf7bd37.tar.xz
Add ResponseCache tests. (#9458)
Diffstat (limited to 'synapse/util/caches')
-rw-r--r--synapse/util/caches/response_cache.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/synapse/util/caches/response_cache.py b/synapse/util/caches/response_cache.py
index 32228f42ee..46ea8e0964 100644
--- a/synapse/util/caches/response_cache.py
+++ b/synapse/util/caches/response_cache.py
@@ -13,17 +13,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import logging
-from typing import TYPE_CHECKING, Any, Callable, Dict, Generic, Optional, TypeVar
+from typing import Any, Callable, Dict, Generic, Optional, TypeVar
 
 from twisted.internet import defer
 
 from synapse.logging.context import make_deferred_yieldable, run_in_background
+from synapse.util import Clock
 from synapse.util.async_helpers import ObservableDeferred
 from synapse.util.caches import register_cache
 
-if TYPE_CHECKING:
-    from synapse.app.homeserver import HomeServer
-
 logger = logging.getLogger(__name__)
 
 T = TypeVar("T")
@@ -37,11 +35,11 @@ class ResponseCache(Generic[T]):
     used rather than trying to compute a new response.
     """
 
-    def __init__(self, hs: "HomeServer", name: str, timeout_ms: float = 0):
+    def __init__(self, clock: Clock, name: str, timeout_ms: float = 0):
         # Requests that haven't finished yet.
         self.pending_result_cache = {}  # type: Dict[T, ObservableDeferred]
 
-        self.clock = hs.get_clock()
+        self.clock = clock
         self.timeout_sec = timeout_ms / 1000.0
 
         self._name = name