A Python function wrapper to cache method results using memcache
Project description
A Python function wrapper to cache method results using memcache
Usage:
from memcache_wrapper import Memcached
from mockcache import Client
mc_client = Client()
@Memcached('/myprefix', mc_client)
def myfunc(args):
...
or
mc = Memcached('/myprefix', mc_client)
cached_myfunc = mc.wrap(myfunc)
For short,
cached_myfunc = Memcached('/myprefix', mc_client).wrap(myfunc)
See more examples at test/test_memcache_wrapper.py
Parameters:
prefix: used as memached's key prefix
mc_client: memcache client instance, such as python-memcached or mockcache
ttl: time to live in memcache, default: 10
bypass_cache: if True, bypass cache and save the result
cache_negative: if False, do not cache negative result, such as [], {}, and None. Otherwise, it will cache everything.
Usage:
from memcache_wrapper import Memcached
from mockcache import Client
mc_client = Client()
@Memcached('/myprefix', mc_client)
def myfunc(args):
...
or
mc = Memcached('/myprefix', mc_client)
cached_myfunc = mc.wrap(myfunc)
For short,
cached_myfunc = Memcached('/myprefix', mc_client).wrap(myfunc)
See more examples at test/test_memcache_wrapper.py
Parameters:
prefix: used as memached's key prefix
mc_client: memcache client instance, such as python-memcached or mockcache
ttl: time to live in memcache, default: 10
bypass_cache: if True, bypass cache and save the result
cache_negative: if False, do not cache negative result, such as [], {}, and None. Otherwise, it will cache everything.
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
Built Distribution
File details
Details for the file memcache_wrapper-1.0.4.tar.gz
.
File metadata
- Download URL: memcache_wrapper-1.0.4.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5258635e038009793b1cb649c477fe0accece3084bcee2a3910ec841f1ee564b |
|
MD5 | dc981b04b1f699cc83b1fcd94e7b115a |
|
BLAKE2b-256 | b889586284c85a9dd09eff067e1e838cd81f694a072705d4a0b91f05eda3c478 |
File details
Details for the file memcache_wrapper-1.0.4-py2-none-any.whl
.
File metadata
- Download URL: memcache_wrapper-1.0.4-py2-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd556d879eba3d07382c95356fb01c3e7d1acea38de02f7ef17c8d3bc5c26cf7 |
|
MD5 | 4ccc78570f6626c2f27c0851ea265ff8 |
|
BLAKE2b-256 | 08aee8265ef4cffe2d146993c8c00670e93f122198065d9255aede0d69c41dce |