Skip to main content

Redis memoize cache

Project description

pipeline status

What is it is a cache and works on redis so it is suitable for multi threaded and multi process applications. It has been inspired and based on library


To use the file, import rcache and annotate functions with @rcache.rcache().

import rcache

def expensive_func(arg, kwarg=None):
  # Expensive stuff here
  return arg

The @rcache.rcache() function can take multiple arguments.

  • @rcache.rcache(timeout=20) - Only caches the function for 20 seconds.
  • @rcache.rcache(url="http://other_redis:6379") - Saves cache to specified Redis url (defaults to http://localhost:6379)
  • @rcache.rcache(key=rcache.ARGS[KWARGS,NONE]) - Check against args, kwargs or neither of them when doing a cache lookup.

How it works queries redis and checks against the name, arguments and hash of a function's source to decide if the function has been run before. If it has it returns the cached result immediately.

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 rcache, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size rcache-1.0.0-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rcache-1.0.0.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page