Files
aiData/clear_sql_cache.py

36 lines
1000 B
Python
Raw Normal View History

2026-01-21 08:41:47 +08:00
import asyncio
import os
import sys
# Add current directory to path so we can import Util
sys.path.append(os.getcwd())
from Util.RedisKit import redisKit
async def clear_cache():
print("Connecting to Redis...")
# redisKit will automatically ensure pool on first operation
keys_to_delete = [
"sql_templates:templates_loaded",
"sql_templates:all_templates",
"sql_templates:loaded_files",
"sql_templates:template_map"
]
for key in keys_to_delete:
print(f"Deleting key: {key}")
# Assuming delete_data exists in redisKit based on common naming convention
# If it doesn't, we can use a raw delete command
try:
await redisKit.delete_data(key)
except AttributeError:
conn = await redisKit.get_connection()
await asyncio.to_thread(conn.delete, key)
print("SQL template cache cleared successfully.")
if __name__ == "__main__":
asyncio.run(clear_cache())