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