Revert "Fix linting"

This reverts commit abd9de2a63b39021320855fab9f5c3b332dee162.
This commit is contained in:
yangdx 2025-06-29 22:35:26 +08:00
parent 75ea0bc38d
commit 10cd9c90e7

View File

@ -86,39 +86,32 @@ class RedisKVStorage(BaseKVStorage):
result = {} result = {}
pattern = f"{self.namespace}:*" pattern = f"{self.namespace}:*"
cursor = 0 cursor = 0
while True: while True:
cursor, keys = await redis.scan( cursor, keys = await redis.scan(cursor, match=pattern, count=100)
cursor, match=pattern, count=100
)
if keys: if keys:
# Batch get values for these keys # Batch get values for these keys
pipe = redis.pipeline() pipe = redis.pipeline()
for key in keys: for key in keys:
pipe.get(key) pipe.get(key)
values = await pipe.execute() values = await pipe.execute()
# Check each value for cache_type == "extract" # Check each value for cache_type == "extract"
for key, value in zip(keys, values): for key, value in zip(keys, values):
if value: if value:
try: try:
data = json.loads(value) data = json.loads(value)
if ( if isinstance(data, dict) and data.get("cache_type") == "extract":
isinstance(data, dict)
and data.get("cache_type") == "extract"
):
# Extract cache key (remove namespace prefix) # Extract cache key (remove namespace prefix)
cache_key = key.replace( cache_key = key.replace(f"{self.namespace}:", "")
f"{self.namespace}:", ""
)
result[cache_key] = data result[cache_key] = data
except json.JSONDecodeError: except json.JSONDecodeError:
continue continue
if cursor == 0: if cursor == 0:
break break
return result if result else None return result if result else None
except Exception as e: except Exception as e:
logger.error(f"Error scanning Redis for extract cache entries: {e}") logger.error(f"Error scanning Redis for extract cache entries: {e}")