We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2457ca5 commit 26c5377Copy full SHA for 26c5377
src/app/core/utils/cache.py
@@ -171,14 +171,13 @@ async def _delete_keys_by_pattern(pattern: str) -> None:
171
- Be cautious with patterns that could match a large number of keys, as deleting
172
many keys simultaneously may impact the performance of the Redis server.
173
"""
174
- if client is None:
175
- raise MissingClientError
176
-
177
- cursor = -1
178
- while cursor != 0:
+ cursor = 0 # Make sure cursor starts at 0
+ while True:
179
cursor, keys = await client.scan(cursor, match=pattern, count=100)
180
if keys:
181
await client.delete(*keys)
+ if cursor == 0: # cursor returns to 0 when scan is complete
+ break
182
183
184
def cache(
0 commit comments