Add methods keys, items, values.

This commit is contained in:
voussoir 2024-03-07 19:10:40 -08:00
parent 24f74e9ee4
commit 25fd738a35

View file

@ -80,6 +80,15 @@ class Cache:
except KeyError:
return fallback
def keys(self):
return list(self.cache.keys())
def items(self):
return [(key, value) for (key, (value, timestamp)) in self.cache.items()]
def values(self):
return [value for (value, timestamp) in self.cache.values()]
def pop(self, key):
'''
Remove the key and return its value, or raise KeyError.