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