diff options
author | Richard van der Hoff <richard@matrix.org> | 2020-10-16 15:56:39 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2020-10-16 15:56:39 +0100 |
commit | 0ec0bc3886bd72bdf2f64d455a7d777f4573a4f1 (patch) | |
tree | f92a26944b59e96f8d5bebb394d0e7b50caa6668 /synapse/util/caches/deferred_cache.py | |
parent | Make LruCache register its own metrics (#8561) (diff) | |
download | synapse-0ec0bc3886bd72bdf2f64d455a7d777f4573a4f1.tar.xz |
type annotations for LruCache
Diffstat (limited to 'synapse/util/caches/deferred_cache.py')
-rw-r--r-- | synapse/util/caches/deferred_cache.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/synapse/util/caches/deferred_cache.py b/synapse/util/caches/deferred_cache.py index 91fdc8142d..4026e1f8fa 100644 --- a/synapse/util/caches/deferred_cache.py +++ b/synapse/util/caches/deferred_cache.py @@ -98,7 +98,7 @@ class DeferredCache(Generic[KT, VT]): size_callback=(lambda d: len(d)) if iterable else None, metrics_collection_callback=metrics_cb, apply_cache_factor_from_config=apply_cache_factor_from_config, - ) + ) # type: LruCache[KT, VT] self.thread = None # type: Optional[threading.Thread] @@ -240,11 +240,12 @@ class DeferredCache(Generic[KT, VT]): self.check_thread() if not isinstance(key, tuple): raise TypeError("The cache key must be a tuple not %r" % (type(key),)) + key = cast(KT, key) self.cache.del_multi(key) # if we have a pending lookup for this key, remove it from the # _pending_deferred_cache, as above - entry_dict = self._pending_deferred_cache.pop(cast(KT, key), None) + entry_dict = self._pending_deferred_cache.pop(key, None) if entry_dict is not None: for entry in iterate_tree_cache_entry(entry_dict): entry.invalidate() |