From df99fa8d8208c14e65ff623bb220c659d94aed2e Mon Sep 17 00:00:00 2001 From: Numerlor Date: Fri, 29 Apr 2022 15:40:04 +0200 Subject: clear keys from set expires after deleting them from redis if the expire "cache" is not reset, the class assumes an expire is set, even though no expire was set for the key --- bot/exts/info/doc/_redis_cache.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot/exts/info/doc/_redis_cache.py b/bot/exts/info/doc/_redis_cache.py index 107f2344f..9232a71f2 100644 --- a/bot/exts/info/doc/_redis_cache.py +++ b/bot/exts/info/doc/_redis_cache.py @@ -1,6 +1,7 @@ from __future__ import annotations import datetime +import fnmatch from typing import Optional, TYPE_CHECKING from async_rediscache.types.base import RedisObject, namespace_lock @@ -49,12 +50,15 @@ class DocRedisCache(RedisObject): @namespace_lock async def delete(self, package: str) -> bool: """Remove all values for `package`; return True if at least one key was deleted, False otherwise.""" + pattern = f"{self.namespace}:{package}:*" + with await self._get_pool_connection() as connection: package_keys = [ - package_key async for package_key in connection.iscan(match=f"{self.namespace}:{package}:*") + package_key async for package_key in connection.iscan(match=pattern) ] if package_keys: await connection.delete(*package_keys) + self._set_expires = {key for key in self._set_expires if not fnmatch.fnmatchcase(key, pattern)} return True return False -- cgit v1.2.3