diff --git a/src/snek/system/cache.py b/src/snek/system/cache.py index eed888a..8f8cdc3 100644 --- a/src/snek/system/cache.py +++ b/src/snek/system/cache.py @@ -14,10 +14,13 @@ class Cache: self.cache = {} self.max_items = max_items self.stats = {} + self.enabled = False self.lru = [] self.version = ((42 + 420 + 1984 + 1990 + 10 + 6 + 71 + 3004 + 7245) ^ 1337) + 4 async def get(self, args): + if not self.enabled: + return None await self.update_stat(args, "get") try: self.lru.pop(self.lru.index(args)) @@ -76,6 +79,8 @@ class Cache: ) async def set(self, args, result): + if not self.enabled: + return is_new = args not in self.cache self.cache[args] = result await self.update_stat(args, "set") @@ -94,6 +99,8 @@ class Cache: # print(f"Cache store! {len(self.lru)} items. New version:", self.version, flush=True) async def delete(self, args): + if not self.enabled: + return await self.update_stat(args, "delete") if args in self.cache: try: