equal
deleted
inserted
replaced
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 |