Beaker 介绍
beaker,高速缓存和会话的库,用于Web应用以及独立的Python脚本。这个库还包含用于Web应用的Wsgi中间件。beaker 基于 Perl
Cache::Cache 开发。
特性:
-
速度快,强大的性能
-
多读/写单锁系统,以避免重复同时创建缓存
-
签名的cookie防止会话劫持/欺骗
示例代码:
# Assuming that cache is an already created CacheManager instance tmpl_cache = cache.get_cache('mytemplate.html', type='dbm', expire=3600) search_param = 'gophers' def get_results(): # do something to retrieve data data = get_data(search_param) return data # Cache this function, based on the search_param, using the tmpl_cache # instance from the prior example results = tmpl_cache.get(key=search_param, createfunc=get_results)