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())