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