문제

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?

도움이 되었습니까?

해결책

@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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top