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:
On the horizon for future implementation:
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) @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')
Unlike Beaker’s caching system, this is built strictly for Redis. As such, it adds several features that Beaker doesn’t possess:
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.
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')
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|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|