Skip to content

NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | implement_lru_cache#175

Open
ZabihollahNamazi wants to merge 3 commits into
CodeYourFuture:mainfrom
ZabihollahNamazi:s2-implement-iru-cache
Open

NW | 26-SDC-Mar | Zabihollah Namazi | Sprint 2 | implement_lru_cache#175
ZabihollahNamazi wants to merge 3 commits into
CodeYourFuture:mainfrom
ZabihollahNamazi:s2-implement-iru-cache

Conversation

@ZabihollahNamazi

@ZabihollahNamazi ZabihollahNamazi commented Jun 24, 2026

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

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!

@ZabihollahNamazi ZabihollahNamazi added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Complexity The name of the module. labels Jun 24, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jun 26, 2026
@ZabihollahNamazi ZabihollahNamazi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 27, 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I moved the LinkedList code into its own file linked_list.py and imported it into LruCache

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 28, 2026
@ZabihollahNamazi ZabihollahNamazi added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Complexity The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants