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