跳转到主要内容

一个简化缓存存储和检索的微库

项目描述

https://img.shields.io/travis/LabD/django-cache-results/master.svg?branch=master https://img.shields.io/pypi/v/LabD.svg https://img.shields.io/pypi/l/LabD.svg https://img.shields.io/codecov/c/github/LabD/django-cache-results/master.svg

django-cache-results

一个简化您的缓存代码的微库。

用法

def key_function(arg1, arg2):
    return f"prefix.{arg1}.{arg2}"

@cache_results(key_function=key_function)
def some_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

并在您的项目中使用它

from cache_results import cache_results

贡献

您是否错过了什么,或者对这个模块不喜欢?给我们发送一个拉取请求!

项目详情


支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面