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