app/soc/cache/base.py
changeset 1418 50e989482d1b
parent 1307 091a21cf3627
child 1829 c9f30de8804f
equal deleted inserted replaced
1417:8b9e256a3abe 1418:50e989482d1b
    36     """Decorator that caches the result from func.
    36     """Decorator that caches the result from func.
    37     """
    37     """
    38   
    38   
    39     @wraps(func)
    39     @wraps(func)
    40     def wrapper(*args, **kwargs):
    40     def wrapper(*args, **kwargs):
    41       result = get(*args, **kwargs)
    41       result, key = get(*args, **kwargs)
    42       if result:
    42       if result:
    43         return result
    43         return result
    44 
    44 
    45       result = func(*args, **kwargs)
    45       result = func(*args, **kwargs)
    46       put(result, *args, **kwargs)
    46 
       
    47       if key:
       
    48         put(result, key, *args, **kwargs)
       
    49 
    47       return result
    50       return result
    48 
    51 
    49     return wrapper
    52     return wrapper
    50 
    53 
    51   return cache
    54   return cache