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