pip install beaker python import beaker.util as pickle data = {'name': 'John', 'age': 30} pickle.dump(data, open('data.pickle', 'wb')) python import beaker.util as shelve data = shelve.open('data.db') data['name'] = 'John' data['age'] = 30 data.close() python from beaker.cache import CacheManager cache = CacheManager() python def expensive_function(arg1, arg2): return result python import beaker.util as pickle from beaker.cache import CacheManager data = {'name': 'John', 'age': 30} pickle.dump(data, open('data.pickle', 'wb')) cache = CacheManager() @cache.cache('my_cache', expire=3600) def expensive_function(arg1, arg2): return result


上一篇:
下一篇:
切换中文