def invalidate_callable(callable, *args):
    """Invalidate the cache for a callable

    :param callable: The callable that was cached
    :type callable: callable object
    :param \*args: Arguments the function was called with that
                   should be invalidated. If the args is just the
                   differentiator for the function, or not present, then all
                   values for the function will be invalidated.

    Example::

        @cache_region('short_term', 'small_engine')
        def local_search(search_term):
            # do search and return it

        @cache_region('long_term')
        def lookup_folks():
            # look them up and return them

        # To clear local_search for search_term = 'fred'
        invalidate_function(local_search, 'fred')

        # To clear all cached variations of the local_search function
        invalidate_function(local_search)

        # To clear out lookup_folks
        invalidate_function(lookup_folks)

    """
    redis = global_connection.redis
    region = callable._region
    namespace = callable._namespace

    # Get the expiration for this region
    new_created = time.time() - CacheRegion.regions[region]['expires'] - 3600

    if args:
        try:
            cache_key = " ".join(map(str, args))
        except UnicodeEncodeError:
            cache_key = " ".join(map(unicode, args))
        redis.hset('retools:%s:%s:%s' % (region, namespace, cache_key),
                   'created', new_created)
    else:
        cache_keyset_key = 'retools:%s:%s:keys' % (region, namespace)
        keys = set(['']) | redis.smembers(cache_keyset_key)
        p = redis.pipeline(transaction=True)
        for key in keys:
            p.hset('retools:%s:%s:%s' % (region, namespace, key), 'created',
                   new_created)
        p.execute()
    return None
dataset/ETHPy150Open bbangert/retools/retools/cache.py/invalidate_callable/original