Skip to main content

A Python function wrapper to cache method results using memcache

Project description

A Python function wrapper to cache method results using memcache


from memcache_wrapper import Memcached
from mockcache import Client

mc_client = Client()

@Memcached('/myprefix', mc_client)
def myfunc(args):


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/


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.

Files for memcache_wrapper, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size memcache_wrapper-1.0.4-py2-none-any.whl (4.0 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size memcache_wrapper-1.0.4.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page