Skip to content

Commit

Permalink
develop cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hlibswork committed Nov 23, 2024
1 parent 5891c38 commit 6313c4e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@


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

def wrapper(*args):
if args in cached_results:
print("Getting from cache")
return cached_results[args]
result = func(*args)
cached_results[args] = result
print("Calculating new result")
return result
return wrapper

0 comments on commit 6313c4e

Please sign in to comment.