From 81ca5236880295e5348f1ca5954d00e9e013a163 Mon Sep 17 00:00:00 2001 From: Ilia Terentev Date: Sat, 2 Nov 2024 20:10:47 +0200 Subject: [PATCH] Solution --- app/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 68287892..5def11c2 100644 --- a/app/main.py +++ b/app/main.py @@ -2,5 +2,15 @@ def cache(func: Callable) -> Callable: - # Write your code here - pass + cache_list = {} + + def storage(*args, **kwargs) -> int: + if args not in cache_list.keys(): + cache_list[args] = func(*args, **kwargs) + print("Calculating new result") + else: + print("Getting from cache") + + return cache_list[args] + + return storage