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:

```python
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

```text
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:

```python
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

```text
do utils
do api/template cache for tornado server with redis
```

- v0.0.2

```text
bugfix for install_requires cannot using 'requirements.txt'
add prefix for cache_key: 'cache:'
```

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.2.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file do-utils-0.0.2.tar.gz.

File metadata

  • Download URL: do-utils-0.0.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for do-utils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 933b0e759854fe2731aaf7f01f0694c5240cc595e563f7736605b30e9f6c8d44
MD5 d6d202e9bc80fe1a92de57a19e68b1aa
BLAKE2b-256 168cd50a4b7d0140d17cffc1ffaef3fadbd279049d126a34b762e6042ea8efb3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page