<commit_before>=====================
Redis Tools (retools)
=====================

``retools`` is a package of Redis tools.

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
    
    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')


Locking
=======

A Redis based lock implemented as a Python context manager, based on `Chris
Lamb's example
<http://chris-lamb.co.uk/2010/06/07/distributing-locking-python-and-redis/>`_.

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 `<NAME>`.<commit_msg>Add example of invalidate function<commit_after>=====================
Redis Tools (retools)
=====================

``retools`` is a package of Redis tools.

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')


Locking
=======

A Redis based lock implemented as a Python context manager, based on `Chris
Lamb's example
<http://chris-lamb.co.uk/2010/06/07/distributing-locking-python-and-redis/>`_.

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 `<NAME>`.
{'fraction_non_alphanumeric': 0.1202113606340819, 'fraction_numerical': 0.010568031704095112, 'mean_word_length': 3.8541666666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5118645', 'n_tokens_mistral': 922, 'n_tokens_neox': 838, 'n_words': 323}