-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Sometimes I need to invalidate the cache or need an empty cache in my tests. I didn't see any simple solution to clear it.
Currently im doing it like this:
from cache import AsyncTTL
@AsyncTTL(...)
async def my_function(...):
...in order to clear the cache I have to this:
my_function.__closure__[1].cell_contents.ttl.clear()it would be nice to have this function easily accessible like (same as functools.lru):
my_function.clear_cache()and maybe even have access to the non-wrapped function with:
my_function.__wrapped__which would be useful to disable cache during tests my mocking the cached function in conftest.py:
@pytest.fixture(auto_use=True)
def no_cache(monkeypatch):
monkeypatch.setattribute(my_module, 'my_function', my_module.my_function.__wrapped__)Would be a nice improvement if something like this would be implemented :)
luca-arch and gumelarme
Metadata
Metadata
Assignees
Labels
No labels