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
from time import sleep
@do_time()
def do_print():
sleep(0.01)
class A(object):
@do_time(func=False)
def do_print(self):
sleep(0.01)
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
- v0.0.4.2
bugfix for Python3 and update dependence
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
do_utils-0.0.4.2.tar.gz
(9.6 kB
view details)
Built Distribution
File details
Details for the file do_utils-0.0.4.2.tar.gz
.
File metadata
- Download URL: do_utils-0.0.4.2.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 282be9c3b5802ebab0b240bb0553e713c1f46a7f3739e5839644df1f1234b1a3 |
|
MD5 | 48f70f20275fcde5b306ff632b3a248f |
|
BLAKE2b-256 | b7c7a1c9cee77fc4887062a6523244451014cf6e284cce239a7b9cb1879ac47f |
File details
Details for the file do_utils-0.0.4.2-py3-none-any.whl
.
File metadata
- Download URL: do_utils-0.0.4.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 781c483c8f3409d55d6bd326db3793f4eda8c2920f615b1636f06542a40b7902 |
|
MD5 | 7701bd3e6737781dabd45997be2bc222 |
|
BLAKE2b-256 | eed6cee5d9ba010f7878e47dcf158498c6ab59ddff3b94eb6265e48765652d9e |