This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
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.

Caching

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.

Example:

from retools.cache import CacheRegion, cache_region, invalidate_function

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

@cache_region('short_term')
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.

Locking

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

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

License

retools is offered under the MIT license.

Authors

retools is made available by Ben Bangert.

Changelog

0.4.1 (02/19/2014)

Bug Fixes

  • Properly support StrictRedis with ZADD (used in the limiter). Patch by Bernardo Heynemann.

0.4 (01/27/2014)

Features

  • Added limiter functionality. Pull request #22, by Bernardo Heynemann.

0.3 (08/13/2012)

Bug Fixes

  • Call redis.expire with proper expires value for RedisLock. Patch by Mike McCabe.
  • Use functools.wraps to preserve doc strings for cache_region. Patch by Daniel Holth.

API Changes

  • Added get_job/get_jobs methods to QueueManager class to get information on a job or get a list of jobs for a queue.

0.2 (02/01/2012)

Bug Fixes

  • Critical fix for caching that prevents old values from being displayed forever. Thanks to Daniel Holth for tracking down the problem-aware.
  • Actually sets the Redis expiration for a value when setting the cached value in Redis. This defaults to 1 week.

Features

  • Statistics for the cache is now optional and can be disabled to slightly reduce the Redis queries used to store/retrieve cache data.
  • Added first revision of worker/job Queue system, with event support.

Internals

  • Heavily refactored Connection to not be a class singleton, instead a global_connection instance is created and used by default.
  • Increased conditional coverage to 100% (via instrumental).

Backwards Incompatibilities

  • Changing the default global Redis connection has changed semantics, instead of using Connection.set_default, you should set the global_connection’s redis property directly:

    import redis
    from retools import global_connection
    
    global_connection.redis = redis.Redis(host='myhost')
    

Incompatibilities

  • Removed clear argument from invalidate_region, as removing keys from the set but not removing the hit statistics can lead to data accumulating in Redis that has no easy removal other than .keys() which should not be run in production environments.
  • Removed deco_args from invalidate_callable (invalidate_function) as its not actually needed since the namespace is already on the callable to invalidate.

0.1 (07/08/2011)

Features

  • 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
Release History

Release History

0.4.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1dev

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
retools-0.4.1-py2.py3-none-any.whl (30.9 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Feb 20, 2014
retools-0.4.1.tar.gz (32.6 kB) Copy SHA256 Checksum SHA256 Source Feb 20, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting