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