我有一个这样的缓存方法:
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):
....
我需要通过另一种方法以编程方式使用此缓存,以使某些(并非全部)缓存值显式无效。我怎样才能做到这一点?
@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)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句