2014-01-23 40 views
0

我有这样一个缓存的方法:烧杯:如何以编程方式访问装饰器创建的缓存?

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): 
    .... 

我需要从另一种方法以编程方式使用此高速缓存来显式无效的一些(不是全部)的缓存值。我怎样才能做到这一点?

回答

1
@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)