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