Question

I have a cached method like this:

from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options

cache = CacheManager(**parse_cache_config_options({'cache.type': 'memory'}))

@cache.cache('test',expire=100000)
def f(x,y,z=True):
    ....

I need to use this cache programmatically from another method to invalidate some (not all) cached values explicitly. How can I do this?

Was it helpful?

Solution

@cache.cache('test', expire=10000)
def plus(x, y):
    return x + y

plus(8, 9)
plus(11, 12)

# invalidate plus(11, 12)
cache.invalidate(plus, 'test', 11, 12, expire=10000)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top