Track cache invalidations (#12000)

Currently we only track evictions due to size or time constraints.
This commit is contained in:
Erik Johnston 2022-02-15 14:31:04 +00:00 committed by GitHub
parent dc9fe61050
commit 0dbbe33a65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View file

@ -560,8 +560,10 @@ class LruCache(Generic[KT, VT]):
def cache_pop(key: KT, default: Optional[T] = None) -> Union[None, T, VT]:
node = cache.get(key, None)
if node:
delete_node(node)
evicted_len = delete_node(node)
cache.pop(node.key, None)
if metrics:
metrics.inc_evictions(EvictionReason.invalidation, evicted_len)
return node.value
else:
return default