Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
WoyDiam committed Sep 21, 2023
1 parent 82317fd commit c8c4035
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ def cache(func: Callable) -> Callable:

def wrapper(*args, **kwargs) -> Any:
key = (args, frozenset(kwargs.items()))
if key in cache_dict:
print("Getting from cache")
return cache_dict[key]
else:
if key not in cache_dict:
print("Calculating new result")
result = func(*args, **kwargs)
cache_dict[key] = result
return result
cache_dict[key] = func(*args, **kwargs)
else:
print("Getting from cache")
return cache_dict[key]

return wrapper

0 comments on commit c8c4035

Please sign in to comment.