'commit'
This commit is contained in:
35
clear_sql_cache.py
Normal file
35
clear_sql_cache.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
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())
|
||||
Reference in New Issue
Block a user