Skip to content

Commit

Permalink
task completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Atom-gnomov committed Dec 21, 2024
1 parent 5891c38 commit d00f7d9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,16 @@


def cache(func: Callable) -> Callable:
# Write your code here
pass
cache_save = {}

def wrapper(*args, **kwargs) -> any:
cache_key = (args, tuple(sorted(kwargs.items())))
if cache_key in cache_save:
print("Getting from cache")
return cache_save[cache_key]
else:
print("Calculating new result")
result = func(*args, **kwargs)
cache_save[cache_key] = result
return result
return wrapper

0 comments on commit d00f7d9

Please sign in to comment.