Giter VIP home page Giter VIP logo

retools's Introduction

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.
Build Status

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.

retools's People

Contributors

bbangert avatar tarekziade avatar dholth avatar rhelmer avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.