0

我们可以将任何视图/非视图函数缓存为

@cache.cached(timeout=50, key_prefix='all_comments')

我们可以给 key_prefix 一些变量值吗?假设,我将一个函数缓存为

@cache.cached(timeout=50, key_prefix=value)
def get_all_comments(value):

我们可以给 key_prefix 作为我们在函数中获得的相同参数吗?如果不是参数,那么以任何适当的方式至少有一些其他变量。

4

1 回答 1

1

In the docs it says

New in version 0.3.4: Can optionally be a callable which takes no arguments but returns a string that will be used as the cache_key.

于 2014-01-09T14:47:35.153 回答