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