Spaces:
Paused
Paused
Download scratch/clear_user_cache.py from 3SCError404/miracle: direct link, hf CLI and curl.
- Browser
- Download file 883 Bytes
-
https://huggingface.co/spaces/3SCError404/miracle/resolve/main/scratch/clear_user_cache.py
- Command line
-
hf download hf://spaces/3SCError404/miracle/scratch/clear_user_cache.py
-
curl -L -o clear_user_cache.py https://huggingface.co/spaces/3SCError404/miracle/resolve/main/scratch/clear_user_cache.py
883 Bytes
| import asyncio | |
| import sys | |
| if sys.platform == "win32": | |
| asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) | |
| from core.cache import invalidate_cache | |
| from sqlalchemy import select | |
| from core.database import async_session_factory | |
| from models.user import User | |
| async def clear_cache(): | |
| async with async_session_factory() as db: | |
| stmt = select(User).where(User.full_name.ilike("%ANSELL LEAD%")) | |
| res = await db.execute(stmt) | |
| user = res.scalar_one_or_none() | |
| if not user: | |
| print("User not found") | |
| return | |
| cache_key = f"workspaces:user:{user.id}" | |
| print(f"Invalidating cache for user: {user.full_name} ({user.id})") | |
| print(f"Key: {cache_key}") | |
| await invalidate_cache(cache_key) | |
| print("Done") | |
| if __name__ == "__main__": | |
| asyncio.run(clear_cache()) | |