Add methods keys, items, values.

master
voussoir 2024-03-07 19:10:40 -08:00
parent 24f74e9ee4
commit 25fd738a35
1 changed files with 9 additions and 0 deletions

View File

@ -80,6 +80,15 @@ class Cache:
except KeyError: except KeyError:
return fallback 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): def pop(self, key):
''' '''
Remove the key and return its value, or raise KeyError. Remove the key and return its value, or raise KeyError.