I have a function which is decorated with beaker cache decorator. The function is located in a module from which it is imported into the main app.
from caching import cache, my_cached_function
Now, in one function I used the decorated function:
def index():
data = my_cached_function() # no args
In another function, I try to invalidate the cache:
def new_item():
cache.invalidate(my_cached_function, 'namespace')
Since Beaker cache is configured with 'cache.type': 'memory'
, I've also tried:
def new_item():
cache.invalidate(my_cached_function, 'namespace', type='memory')
What am I doing wrong here?
NOTES
In a typical scenario, I would call index() most of the time. I need the cache to be cleared whenever new_item() is called, so that the index() call will take into account the new items created by new_item() function.
The application in question is a web application running on top of bottle framework.
You need to invalidate the cache before
my_cached_function
is called. See the beaker.cache.CacheManager documentation for an example.