django函数和方法的简单缓存

django-elephant的Python项目详细描述


#Django大象

[![构建状态](https://travis ci.org/jairhenrique/django elephant.svg)(https://travis ci.org/jairhenrique/django elephant)
[![PYPI版本](https://badge.fury.io/py/django elephant.svg)(https://badge.fury.io/py/django elephant)
[![codecov.io](https://codecov.io/github/jairhenrique/django-elephant/coverage.svg?branch=master)(https://codecov.io/github/jairhenrique/django-elephant?分支=主)
[![代码问题](https://www.quantifiedcode.com/api/v1/project/03084631935244baa8335617d6502d11/badge.svg)(https://www.quantifiedcode.com/app/project/03084631935244baa8335617d6502d11)



*django elephant是缓存django方法或函数的响应的简单包装器*


django-elephant
```

## Usage

#### Basic:

```python
from elephant import memorize

@memorize()
def foo(bar):
return bar
```


#### Set cache configuration:

```python
from django.core.cache import caches
from elephant import memorize

other_cache = 缓存['other_cache']


@memmemory(
>cache=other_cache

def foo(bar):
returnbar
````





` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` py ` ` ` ` ` ` ` ` `:
返回条
````

密钥:

``来自大象导入的python


def my_custom_key(函数,*参数,**kwargs:
return{{}.{{}.{{}.format(
‘大象’函数。
函数名。





@memmemory(
cache-key=my自定义键

def foo(酒吧):
return bar
````



需求
-django>;=1.5





















贡献
-分叉并发出拉动请求!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java FirebaseInstancedService已被弃用,我在重写代码时迷失了方向   java ObjectAnimator不设置动画   hashmap在Java中从映射获取值   javascript如何从Html停止Servlet重定向   java抑制嵌入式Jetty服务器版本   java使用算术运算,一共进了多少球?   java手势与WebView   mapreduce在Java中应用Map Reduce   java试图使用泛型延迟加载安卓视图   java如何防止tomcat启动时初始化的类对数据库的双重写入?   Java:启动。参数处于隐藏模式的exe应用程序,并将其输出到主应用程序中?   java My Spigot Minecraft插件在我吃东西时不会说“yum”   java如何在春季将列表对象上传到模型中?   即使存在getter,也会发生java PropertyNotFoundException   java如何将一个字符串转换为另一个字符串,从而在输出中不允许使用特定字符?   java如何在reducer输出中从partr00000中删除r00000