From f7b56c533df7bf8c520f5cf69df5bf6dd62cf2dc Mon Sep 17 00:00:00 2001 From: Numerlor <25886452+Numerlor@users.noreply.github.com> Date: Fri, 5 Mar 2021 02:44:25 +0100 Subject: Clarify the use of _set_expires and needs_expire --- bot/exts/info/doc/_redis_cache.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bot/exts/info/doc/_redis_cache.py b/bot/exts/info/doc/_redis_cache.py index 7de2f3806..ad764816f 100644 --- a/bot/exts/info/doc/_redis_cache.py +++ b/bot/exts/info/doc/_redis_cache.py @@ -30,6 +30,9 @@ class DocRedisCache(RedisObject): with await self._get_pool_connection() as connection: if redis_key not in self._set_expires: + # An expire is only set if the key didn't exist before. + # If this is the first time setting values for this key check if it exists and add it to + # `_set_expires` to prevent redundant checks for subsequent uses with items from the same page. self._set_expires.add(redis_key) needs_expire = not await connection.exists(redis_key) -- cgit v1.2.3