BeakerPython 高速緩存和會話庫
Beaker,高速緩存和會話的庫,用于Web應(yīng)用以及獨立的Python腳本。這個庫還包含用于Web應(yīng)用的WSGI中間件。Beaker 基于 Perl Cache::Cache 開發(fā)。
特性:
-
速度快,強大的性能
-
多讀/寫單鎖系統(tǒng),以避免重復(fù)同時創(chuàng)建緩存
-
緩存后端包括DBM,文件,內(nèi)存,memcached和數(shù)據(jù)庫
-
簽名的cookie防止會話劫持/欺騙
-
唯一的Cookie會話來刪除一個數(shù)據(jù)庫或文件后端
示例代碼:
# 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)評論
圖片
表情
