mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 16:44:48 -04:00
type annotations for LruCache
This commit is contained in:
parent
3ee17585cd
commit
0ec0bc3886
5 changed files with 89 additions and 31 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue