Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dizatvarska committed Nov 16, 2024
1 parent e30e510 commit b33fa21
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
def cache(func: Callable) -> Any:
results = {}

def wrapper(*args, **kwargs) -> Any:
def wrapper(*args) -> Any:
if args in results:
print(f"Getting from cache {results[args]}")
print("Getting from cache")
return results[args]
else:
result = func(*args)
results[args] = result
print(f"Calculating new result {result}")
print("Calculating new result")
return result
return wrapper

0 comments on commit b33fa21

Please sign in to comment.