Cache function result with args for Django.
Project description
Cache Fn
Use django cache to cache the function(*arg, **kw)
with timeout.
Quick start
- Install::
pip install django-cache-fn
- Start to use it in code
from cache_fn.decorators import cache_fn
@cache_fn(prefix='myprefix', timeout=3600)
def foo(k1, k2):
return "%s %s"%(k1, k2)
Usage
def cache_fn(timeout=1, prefix=None, cache_ttl=MEMCACHE_MAX_EXPIRATION):
"""
Retrieve data from cache if cacheable and no-stale,
otherise refresh synchronously and cache it.
* timeout: The stale timeout which would be handled in the decorator.
* prefix: The prefix of cache key.
* cache_ttl: The TTL(time to live) of key in memcache.
NOTE: For HttpResponse, we just cache the response whose status code is 200.
"""
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-cache-fn-1.1.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file django-cache-fn-1.1.tar.gz
.
File metadata
- Download URL: django-cache-fn-1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8c42f83611dcbfc94c5aa7813e46eb346893458e318a9c1dbc7e29889284f99 |
|
MD5 | 3074c6c89e8fea32075d6ca81fead4d3 |
|
BLAKE2b-256 | 309ef4212d4590d91cd65e186ddf67feca1736d0e6b98058ced4422dc7e10442 |
File details
Details for the file django_cache_fn-1.1-py3-none-any.whl
.
File metadata
- Download URL: django_cache_fn-1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.29.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c4fec03c9f660cb5500b23840bf122eb0c6f6fd6987af2e7c30f34ab6ffa36a |
|
MD5 | 7cc1b0e04982130e330d7cc4275991e9 |
|
BLAKE2b-256 | 36199469cd363747f06e5befaaa3add0b4637cf2729d3f61c813364d852513f0 |