Skip to content

Birmingham | 26-Jul-SDC | Merve Reis | Sprint 2 | Implement LRU Cache in Phyton - #246

Open
mervereis wants to merge 2 commits into
CodeYourFuture:mainfrom
mervereis:sprint2-implement-lru-cache
Open

mervereis wants to merge 2 commits into
CodeYourFuture:mainfrom
mervereis:sprint2-implement-lru-cache

Conversation

@mervereis

@mervereis mervereis commented Oct 13, 2026 •

Copy link
Copy Markdown

Learners, PR Template

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

Task code

CYF-1181

Changelist

Implemented an LruCache class with O(1) average-time get and set operations using a dictionary and doubly linked list.

@github-actions

This comment has been minimized.

@mervereis mervereis added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 13, 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.

You could copy your linked_list.py to this folder.

Alternatively, use a suitable Python built-in class to mantian 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 Oct 13, 2026
@mervereis

Copy link
Copy Markdown
Author

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.

You could copy your linked_list.py to this folder.

Alternatively, use a suitable Python built-in class to mantian order.

Could you update your code using one of these approaches?

“I made a separate linked list to track which cache items were used recently. The cache removes the least recently used item when it is full.” @cjyuan

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

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants