0

In FastAPI I have an endpoint:

from aiocache import Cache, cached

@router.get("/id/{user_id}/permissions")
@cached(ttl=30, cache=Cache.MEMORY)
async def get_permissions(user_id: UUID4) -> list[Permissions]:

And then in my unit test, I want to clear the cache.

I have tried recreating the cache with a namespace, key. Currently I have:

from my_module import get_permissions

my_cache = get_permissions.cache
await my_cache.clear()

I have tried every imaginable combination. But I cannot get this asynchronous test to clear my cache. Any ideas? What am I doing wrong? Could it be there are in different processes?

DUDANF
  • 2,618
  • 1
  • 12
  • 42

0 Answers0