From 210d5ed5bbb020324ef81d2700aa03b50cf636db Mon Sep 17 00:00:00 2001 From: Nikita Mazurenko Date: Sat, 23 May 2026 21:21:49 +0200 Subject: [PATCH] Solution --- app/main.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 68287892f..0a6e17c54 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,19 @@ +from functools import wraps from typing import Callable def cache(func: Callable) -> Callable: - # Write your code here - pass + storage_cache = {} + + @wraps(func) + def wrapper(*args, **kwargs) -> Callable: + key = (args, tuple(kwargs.items())) + if key not in storage_cache: + result = func(*args, **kwargs) + storage_cache[key] = result + print("Calculating new result") + return result + else: + print("Getting from cache") + return storage_cache[key] + return wrapper