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