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向dropup html/css添加项目   如何从java中的向量向量打印   Java Maven库项目模板   java使用atmosphere api还是直接使用grizzly?   java JComponent仅部分显示   如何将动态值传递给自定义注释,以从Java数据进行映射。性质   java破解已实现方法的返回类型的最佳方法?   java Netbeans在JFrame Gui布局中覆盖图像   spring java仅向登录用户显示注销按钮   java如何对com进行身份验证。谷歌。云bigquery。带有服务帐户的BigQuery`   java禁止空字符串参数和抛出RuntimeException以阻止方法继续的利弊   java分析项目中的所有JAR以获取版本和许可证信息   Java,数据库为什么要分配一个新对象,而我们可以直接将它放入数据库