From 25fd738a351d29aabb0722e8d7c07321a728d50e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 7 Mar 2024 19:10:40 -0800 Subject: [PATCH] Add methods keys, items, values. --- voussoirkit/cacheclass.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/voussoirkit/cacheclass.py b/voussoirkit/cacheclass.py index 5203878..ab1bb4f 100644 --- a/voussoirkit/cacheclass.py +++ b/voussoirkit/cacheclass.py @@ -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.