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