Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov-s-od committed Sep 28, 2023
1 parent 5891c38 commit 5f4dbd3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@


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

def inner(*args, **kwargs) -> None:
key = args

if key in cache_dict:
print("Getting from cache")
return cache_dict[key]
else:
print("Calculating new result")
result = func(*args, **kwargs)
cache_dict[key] = result

return result

return inner

0 comments on commit 5f4dbd3

Please sign in to comment.