【文件属性】:
文件名称:django-throttleandcache:缓存任意函数调用的结果!
文件大小:12KB
文件格式:ZIP
更新时间:2021-06-22 18:19:28
Python
特征
优雅的错误处理(可以回退到缓存值)
在后台计算结果(需要 )
可读的持续时间字符串(“1 天”与 86400)
正确处理 None
每次调用失效
安装
pip 安装 django-throttleandcache
在 settings.py 文件中设置缓存后端。
用法
from throttleandcache import cache
# Cache the result of my_function for 3 seconds.
@ cache ( '3s' )
def my_function ():
return 'whatever'
如果使用相同的参数多次调用该函数,将从缓存中获取结果。 为了使该调用的缓存无效,请使用相同的参数调用 my_function.invalidate():
my_function ()
my_function () # R
【文件预览】:
django-throttleandcache-master
----MANIFEST.in(19B)
----README.rst(3KB)
----tests()
--------celeryconfig.py(27B)
--------test_regressions.py(987B)
--------__init__.py(0B)
--------settings.py(205B)
--------test_tdparse.py(1KB)
--------test_caching.py(4KB)
----setup.cfg(21B)
----throttleandcache()
--------models.py(19B)
--------conf.py(976B)
--------pkgmeta.py(186B)
--------decorators.py(6KB)
--------__init__.py(105B)
--------tdparse.py(987B)
--------logging.py(313B)
--------tasks.py(132B)
--------exceptions.py(0B)
----setup.py(2KB)
----.gitignore(41B)