用django的参数缓存函数结果。

django-cache-fn的Python项目详细描述


缓存fn

使用django cache缓存具有超时的function(*arg, **kw)

快速启动

  1. 安装::
   pip install django-cache-fn
  1. 开始在代码中使用它
   from cache_fn.decorators import cache_fn

   @cache_fn(prefix='myprefix', timeout=3600)
   def foo(k1, k2):
      return "%s %s"%(k1, k2)

用法

def cache_fn(timeout=1, prefix=None, cache_ttl=MEMCACHE_MAX_EXPIRATION):
    """
    Retrieve data from cache if cacheable and no-stale,
    otherise refresh synchronously and cache it.
    * timeout: The stale timeout which would be handled in the decorator.
    * prefix: The prefix of cache key.
    * cache_ttl: The TTL(time to live) of key in memcache.
    NOTE: For HttpResponse, we just cache the response whose status code is 200.
    """

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

推荐PyPI第三方库


热门话题
java结合两个Date实例使用Joda创建datetime   带有POI和FileOutputStream的java Swing应用程序性能问题   Java中是否存在类似于Python的异常?   Java中有界通配符的泛型   使用字符和子字符串的java不同输出   在Java中获取LDAP模式   java自定义类在自身上生成ClassNotFoundException   java连接到从internet到通过LAN连接到internet的系统的serversocket   java如何通过maven在jaxws中使用jaxb插件?   java Kerberos如何获取主体或客户端名称?   java应用服务器中是否有JDBC的单点登录解决方案?   java是存储矩阵值以便以后访问的更好方法   Java等级计算器。开始这门课我需要一些帮助   未找到Android“libc++\u shared.so”中的java OpenCV实现   当我使用web配置部署描述符时使用java。xml。它显示了错误   java为什么我的ArrayList的add方法冲突,如何编辑我的自定义add方法   java创建一个以集合为键的映射?   java如何将用户输入到数字三角形中   为什么Java在读取LinkedHashMap时会自动从字符串转换为整数   类动态创建和读取java类