diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-10-16 17:06:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-16 17:06:50 +0100 |
commit | d6094176d1828b7d169016910f5381b90310a885 (patch) | |
tree | 791f582ee2210404f9fe8c1c8317ee42d7080453 /synapse/util/caches/deferred_cache.py | |
parent | Clean-up old transaction IDs on the background worker. (#8544) (diff) | |
parent | review comments (diff) | |
download | synapse-d6094176d1828b7d169016910f5381b90310a885.tar.xz |
Type annotations for LruCache (#8562)
* type annotations for LruCache * changelog * Apply suggestions from code review Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * review comments Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
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() |