diff --git a/app/main.py b/app/main.py index 68287892..c95902bc 100644 --- a/app/main.py +++ b/app/main.py @@ -2,5 +2,19 @@ def cache(func: Callable) -> Callable: - # Write your code here - pass + cache_data = {} + + def wrapper(*args, **kwargs): + key = (args, frozenset(kwargs.items())) + + if key in cache_data: + print("Getting from cache") + return cache_data[key] + + print("Calculating new result") + result = func(*args, **kwargs) + cache_data[key] = result + return result + + return wrapper +