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

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

4

1 回答 1

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)
于 2014-01-23T13:29:20.657 回答