Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

rc, the redis cache

Project Description

rc - the redis cache.

  • easy to use
  • can build cache cluster
  • batch-fetch multiple cache results (do it in parallel for cluster)

For full documentation see


$ pip install rc


A minimal cache example looks like this:

from rc import Cache

cache = Cache()
assert cache.set('key', 'value')
assert cache.get('key') == 'value'
assert cache.get('foo') is None
assert cache.set('list', [1])
assert cache.get('list') == [1]

A cache cluster use a redis cluster as backend:

from rc import CacheCluster

cache = CacheCluster({
    'cache01': {'host': 'redis-host01'},
    'cache02': {'host': 'redis-host02'},
    'cache03': {'host': 'redis-host03'},
    'cache04': {'host': 'redis-host04', 'db': 1},

Cache decorator:

def load(name, offset):
    return load_from_database(name, offset)

rv = load('name', offset=10)

Batch fetch multiple cache results:

assert cache.get_many('key', 'foo') == ['value', None]

# for cache decorated function
def cached_func(param):
    return param

results = []
# with the context manager, the function
# is executed and return a promise
with cache.batch_mode():
    for i in range(10):
for i, rv in enumerate(results):
    assert rv.value == i

Cache invalidation:

# for decorated function
cache.invalidate(load, 'name', offset=10)


If you feel anything wrong, feedbacks or pull requests are welcome.

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(15.4 kB) Copy SHA256 Hash SHA256
Wheel 2.7 Jun 28, 2016
(12.1 kB) Copy SHA256 Hash SHA256
Source None Jun 28, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers