feat: Add POST /flush-cache endpoint to clear all cached data and reset timers
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -155,3 +155,19 @@ def write_cache(sheet_id: str, modified_time: str, data: list | dict) -> None:
|
||||
logger.info(f"Wrote cache for {sheet_id}")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to write cache {sheet_id}: {e}")
|
||||
|
||||
def flush_cache():
|
||||
"""Delete all cache files and reset in-memory state. Returns count of deleted files."""
|
||||
global _DRIVE_SERVICE
|
||||
_LAST_CHECKED.clear()
|
||||
_DRIVE_SERVICE = None
|
||||
|
||||
deleted = 0
|
||||
if CACHE_DIR.exists():
|
||||
for f in CACHE_DIR.glob("*_cache.json"):
|
||||
f.unlink()
|
||||
deleted += 1
|
||||
logger.info(f"Deleted cache file: {f.name}")
|
||||
|
||||
logger.info(f"Cache flushed: {deleted} files deleted, timers reset")
|
||||
return deleted
|
||||
|
||||
Reference in New Issue
Block a user