📜  最简单的flask memcached - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:39.186000             🧑  作者: Mango

代码示例1
from werkzeug.contrib.cache import MemcachedCache
cache = MemcachedCache(['127.0.0.1:11211'])

def get_my_item():
    rv = cache.get('my-item')
    if rv is None:
        rv = calculate_value()
        cache.set('my-item', rv, timeout=5 * 60)
    return rv