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 hashes)
Built Distribution
Close
Hashes for django_cache_fn-1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c4fec03c9f660cb5500b23840bf122eb0c6f6fd6987af2e7c30f34ab6ffa36a |
|
MD5 | 7cc1b0e04982130e330d7cc4275991e9 |
|
BLAKE2b-256 | 36199469cd363747f06e5befaaa3add0b4637cf2729d3f61c813364d852513f0 |