简化缓存存储和检索的微库
django-cache-results的Python项目详细描述
django缓存结果
一个简化缓存代码的微库。
用法:
defkey_function(arg1,arg2):returnf"prefix.{arg1}.{arg2}"@cache_results(key_function=key_function)defsome_function(arg1,arg2):return"COMPLEX DATA"
正常使用:
value=some_function(1,2)
跳过缓存:
value=some_function.bypass_cache(1,2)
更新缓存:
value=some_function.refresh_cache(1,2)
取出手动操作的钥匙:
cache_key=some_function.cache_key(1,2)
安装
从pypi安装模块:
pip install django-cache-results
并在项目中使用:
fromcache_resultsimportcache_results
贡献
这个模块有没有遗漏或不喜欢的地方? 给我们一个请求!