listener/normal/app/utils.py
def memoize(prefix, time=60):
    """
    A simple memoize that caches into memcache, using a simple
    key based on stringing args and kwargs. Keep args simple.
    """
    def decorator(func):
        def wrapper(*args, **kwargs):
            key = hashlib.md5()
            for arg in itertools.chain(args, kwargs):
                key.update(str(arg))
            key = 'memoize:%s:%s' % (prefix, key.hexdigest())
            data = cache.get(key)
            if data is not None:
                return data
            data = func(*args, **kwargs)
            cache.set(key, data, time)
            return data
        return wrapper
    return decorator

    A simple memoize that caches into memcache, using a simple
    key based on stringing args and kwargs. Keep args simple.
    
A simple memoize that caches into memcache, using a simple
key based on stringing args and kwargs. Keep args simple.
A simple memoize that caches into memcache using a simple key based on stringing args and kwargs . Keep args simple .
def memoize(prefix, time=60):
    def decorator(func):
        def wrapper(*args, **kwargs):
            key = hashlib.md5()
            for arg in itertools.chain(args, kwargs):
                key.update(str(arg))
            key = 'memoize:%s:%s' % (prefix, key.hexdigest())
            data = cache.get(key)
            if data is not None:
                return data
            data = func(*args, **kwargs)
            cache.set(key, data, time)
            return data
        return wrapper
    return decorator
def memoize ( prefix , time = 60 ) : def decorator ( func ) : def wrapper ( * args , ** kwargs ) : key = hashlib . md5 ( ) for arg in itertools . chain ( args , kwargs ) : key . update ( str ( arg ) ) key = 'memoize:%s:%s' % ( prefix , key . hexdigest ( ) ) data = cache . get ( key ) if data is not None : return data data = func ( * args , ** kwargs ) cache . set ( key , data , time ) return data return wrapper return decorator
A simple memoize that caches into memcache, using a simple
key based on stringing args and kwargs.
A simple memoize that caches into memcache using a simple key based on stringing args and kwargs .
"""
    A simple memoize that caches into memcache, using a simple
    key based on stringing args and kwargs. Keep args simple.
    """
prefix
time