Skip to content

Cache decorator#2195

Open
diomochkin72-ctrl wants to merge 1 commit intomate-academy:masterfrom
diomochkin72-ctrl:develop
Open

Cache decorator#2195
diomochkin72-ctrl wants to merge 1 commit intomate-academy:masterfrom
diomochkin72-ctrl:develop

Conversation

@diomochkin72-ctrl
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your solution is approved because the cache decorator correctly stores results per decorated function, distinguishes new computations from cached ones, and prints the exact required messages for cache hits and misses. The key construction using args and sorted kwargs ensures that different call signatures are handled consistently, and your implementation avoids duplicated code while using clear, descriptive names that satisfy the checklist requirements. As a minor improvement, consider adding functools.wraps to the wrapper function in app/main.py so that the original function’s name and docstring are preserved for introspection and when stacking decorators. It would also help to add a short docstring to the decorator explaining that it is intended for functions with immutable arguments, since using lists or dicts as arguments would otherwise raise a TypeError when building the cache key. Overall, this is a clean, readable implementation that meets the functional requirements, with only small best-practice enhancements you might apply in future work. Nicely done on implementing effective caching behavior without overcomplicating the design.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants