Skip to main content

Utils for tornado api cache, function timer.

Project description

do_utils

Utils write for common usage.

do_time

Func timer - count func time with decorator

  • Usage:
from do_utils import do_time

@do_time()
def do_print():
    print len([x for x in xrange(10000)])

class A(object):
    @do_time(func=False)
    def do_print(self):
        print len([x for x in xrange(10000)])

do_cache

Do cache for GET request url handler in Tornado server

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
  • Usage:
from do_utils import do_api_cache, do_temp_cache

class ApiHandler(object):
    @do_api_cache(10)
    def get(self):
        print 'get api'

    @do_temp_cache(10, with_user=False)
    def get(self):
        print 'get template'

Change History

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for do-utils, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size do_utils-0.0.3-py3-none-any.whl (10.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size do-utils-0.0.3.tar.gz (5.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page