Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
D1st3f committed Sep 28, 2023
1 parent 495701b commit adeede7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ def cache(func: Callable) -> Callable:
cached_info = {}

def inner(*args, **kwargs) -> int:
# Щоб унеможливити зміну ключа кешу, довелося перетворити
# ключові аргументи у tuple
set_key = (args, tuple(sorted(kwargs.items())))
sorted_kwargs = tuple(sorted(kwargs.items()))
set_key = (args, sorted_kwargs)
if set_key in cached_info:
print("Getting from cache")
return cached_info[set_key]
Expand Down

0 comments on commit adeede7

Please sign in to comment.