Tornado API缓存的实用程序,函数计时器。

do-utils的Python项目详细描述


实用程序

实用程序是为通用而写的。

do_时间

func timer-使用decorator计算func时间

  • 用法:
fromdo_utilsimportdo_time@do_time()defdo_print():printlen([xforxinxrange(10000)])classA(object):@do_time(func=False)defdo_print(self):printlen([xforxinxrange(10000)])

缓存

在Tornado服务器中缓存获取请求URL处理程序

do_cache:
    do cahche for request with uri & user & params
    cache_key include (protocol, host_name, path, md5(current_user, params))
    cache_expire depend on kwargs expire, the default is 5*60s
    cache from write_buffer that have not flushed wrote by self.write() and will be flush
    if cache is none:
        get data & return data & do cache
    else:
        return cache
do_api_cache:
    do cache for api handler
    if status_code == 200:
        do_cache
do_temp_cache:
    do cache for template handler
  • 用法:
fromdo_utilsimportdo_api_cache,do_temp_cacheclassApiHandler(object):@do_api_cache(10)defget(self):print'get api'@do_temp_cache(10,with_user=False)defget(self):print'get template'

更改历史记录

  • v0.0.1
do utils
do api/template cache for tornado server with redis
  • v0.0.2
bugfix for install_requires cannot using 'requirements.txt'
add prefix for cache_key: 'cache:'
  • v0.0.3
bugfix for Python3 and dependence

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

推荐PyPI第三方库


热门话题
java为什么stripVersion不能在带有mojo依赖项的mavendependencyplugin上工作   java存储具有不同功能的大量对象   java Spring MockMvc自定义验证器未在Spring容器中注册/调用   javascript程序编辑实体而不是添加   C++如何在java上检索图形卡信息?   java如何在没有方法参数的方法上使用@cacheable注释的键   java如何获取特定用户或学生的JSON   java可序列化AjaxRequestTarget   java Tomcat 8禁用分块编码过滤器   java这个简单的Swingbase类是线程安全的吗?   java调用Gdi32。使用JNA获取对象   如何使用来自其他类Java Android onClick的方法?   json序列化已经有了id(java.lang.String)的POJO   java使用jsp上传多个文件?   java有没有办法为Android项目在EclipseIndigo上设置JVM参数?   Eclipse中的java,为什么它告诉我添加一个已经存在的分号?   Java中的正则表达式拆分行   Java:在单行中赋值