supycache是Python对缓存的简单封装库,支持包括内存缓存、memcached和redis。
示例代码:
import timeimport supycache@supycache.supycache(cache_key='result')def execute_expensive(): time.sleep(15) return 42print execute_expensive() # This will take 15 seconds to execute ...42print execute_expensive() # ...not this tho', because the value is cached ...42print supycache.default_backend.get('result') # ..keyed as `result`42
评论