diff options
| author | 2022-04-29 15:40:04 +0200 | |
|---|---|---|
| committer | 2022-04-29 16:31:15 +0200 | |
| commit | df99fa8d8208c14e65ff623bb220c659d94aed2e (patch) | |
| tree | dee45b5c21c475fd99624218f400cb4567089c97 | |
| parent | revert bump to markdownify version (diff) | |
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
| -rw-r--r-- | bot/exts/info/doc/_redis_cache.py | 6 |
1 files changed, 5 insertions, 1 deletions
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 |