diff --git a/app/main.py b/app/main.py index 68287892..623ed203 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,17 @@ -from typing import Callable +from typing import Callable, Dict, Tuple def cache(func: Callable) -> Callable: - # Write your code here - pass + cache_store: Dict[Tuple, any] = {} + + + def wrapper(*args): + if args in cache_store: + print("Getting from cache") + return cache_store[args] + else: + print("Calculating new result") + result = func(*args) + cache_store[args] = result + return result + return wrapper()