Skip to content

Commit

Permalink
Removed else and cash_key
Browse files Browse the repository at this point in the history
  • Loading branch information
vshvanska committed Sep 28, 2023
1 parent f6c62b9 commit 37589ae
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ def cache(func: Callable) -> Callable:
caching_results = {}

def wrapper(*args) -> Any:
cach_key = args
if cach_key in caching_results.keys():
if args in caching_results.keys():
print("Getting from cache")
return caching_results[args]
else:
print("Calculating new result")
func_result = func(*args)
caching_results[args] = func_result
return func_result
print("Calculating new result")
func_result = func(*args)
caching_results[args] = func_result
return func_result

return wrapper

0 comments on commit 37589ae

Please sign in to comment.