Skip to main content

Redis Tools

Project description

Redis Tools (retools)

retools is a package of Redis tools. It’s aim is to provide a variety of Redis backed Python tools that are always 100% unit tested, fast, efficient, and utilize the capabilities of Redis.

Current tools in retools:

  • Caching
  • Global Lock

On the horizon for future implementation:

  • A worker/job processing system similar to Celery but based on how Ruby’s Resque system works.


A high performance caching system that can act as a drop-in replacement for Beaker’s caching. Unlike Beaker’s caching, this utilizes Redis for distributed write-locking dogpile prevention. It also collects hit/miss cache statistics along with recording what regions are used by which functions and arguments.


from retools.cache import CacheRegion, cache_region, invalidate_function

CacheRegion.add_region('short_term', expires=3600)

def slow_function(*search_terms):
    # Do a bunch of work
    return results

my_results = slow_function('bunny')

# Invalidate the cache for 'bunny'
invalidate_function(slow_function, [], 'bunny')

Differences from Beaker

Unlike Beaker’s caching system, this is built strictly for Redis. As such, it adds several features that Beaker doesn’t possess:

  • A distributed write-lock so that only one writer updates the cache at a time across a cluster.
  • Hit/Miss cache statistics to give you insight into what caches are less effectively utilized (and may need either higher expiration times, or just not very worthwhile to cache).
  • Very small, compact code-base with 100% unit test coverage.


A Redis based lock implemented as a Python context manager, based on Chris Lamb’s example.


from retools.lock import Lock

with Lock('a_key', expires=60, timeout=10):
    # do something that should only be done one at a time


retools is offered under the MIT license.


retools is made available by Ben Bangert.


Next release

  • Job/Worker system based on Ruby’s Resque model.

0.1 (07/08/2011)


  • Caching in a similar style to Beaker, with hit/miss statistics, backed by a Redis global write-lock with old values served to prevent the dogpile effect
  • Redis global lock

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 retools, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size retools-0.1.tar.gz (12.5 kB) File type Source Python version None Upload date Hashes View

Supported by

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