Skip to content

Commit

Permalink
'keys-and-return-amadments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogober committed Dec 3, 2024
1 parent 64f9833 commit 28c6aa7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from typing import Callable
from typing import Any


def cache(func: Callable) -> Callable:
def cache(func: Any) -> Any:
cache_data = {}

def wrapper(*args) -> Callable:
if args in cache_data.keys():
def wrapper(*args) -> Any:
if args in cache_data:
print("Getting from cache")
return cache_data[args]

cache_data[args] = func(*args)
print("Calculating new result")
else:
cache_data[args] = func(*args)
print("Calculating new result")
return cache_data[args]

return wrapper

0 comments on commit 28c6aa7

Please sign in to comment.