NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | implement_lru_cache#175
Open
ZabihollahNamazi wants to merge 3 commits into
Open
NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | implement_lru_cache#175ZabihollahNamazi wants to merge 3 commits into
ZabihollahNamazi wants to merge 3 commits into
Conversation
cjyuan
reviewed
Jun 26, 2026
cjyuan
left a comment
There was a problem hiding this comment.
To better adhere to the Single-Responsibility Principle (SRP) from SOLID design principles, it's preferable to implement the "doubly linked list" and the "LRU Cache" as separate classes, with the linked list used inside LruCache to manage ordering.
Alternatively, use OrderedDict to maintain order.
Could you update your code using one of these approaches?
cjyuan
reviewed
Jun 28, 2026
Comment on lines
+57
to
+66
| class LruCache: | ||
| def __init__(self, limit: int): | ||
| if limit <= 0: | ||
| raise ValueError("Cache limit must be greater than 0") | ||
|
|
||
| self.limit = limit | ||
| self.lookup = {} | ||
| self.head = None | ||
| self.tail = None | ||
|
|
There was a problem hiding this comment.
This LruCache implementation is still tightly coupled with the code of a linked list.
How could you reuse your Linked List implementation in your LruCache without copying its code?
Author
There was a problem hiding this comment.
I moved the LinkedList code into its own file linked_list.py and imported it into LruCache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Hi! Could you please check my code?
The code handles all cache operations, updates eviction orders correctly, and keeps everything running fast speed.All 5 tests are passing perfectly. Thank you!