Skip to content

Fix AttributeError in LRU cache eviction (missing query on Node) #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

Fix AttributeError in LRU cache eviction (missing query on Node)

Description

The sample LRU cache crashes on eviction because Node instances lack a
query attribute, yet Cache.set() references tail.query when removing the
oldest item.
Added query (and minor docs) to Node and create nodes with both key and
value, eliminating the runtime error and restoring cache functionality.

odiomarcelino and others added 2 commits June 29, 2025 19:38
…ci:2://file:///c:/Users/T2430514/Downloads/system-design-primer/solutions/object_oriented_design/lru_cache/lru_cache.py:0:0-4:24))

The sample LRU cache crashes on eviction because [Node](cci:2://file:///c:/Users/T2430514/Downloads/system-design-primer/solutions/object_oriented_design/lru_cache/lru_cache.py:0:0-4:24) instances lack a
`query` attribute, yet `Cache.set()` references `tail.query` when removing the
oldest item.
Added `query` (and minor docs) to [Node](cci:2://file:///c:/Users/T2430514/Downloads/system-design-primer/solutions/object_oriented_design/lru_cache/lru_cache.py:0:0-4:24) and create nodes with both key and
value, eliminating the runtime error and restoring cache functionality.

Co-Authored-By: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>
The sample LRU cache crashes on eviction because Node instances lack a
query attribute, yet Cache.set() references tail.query when removing the
oldest item.
Added query (and minor docs) to Node and create nodes with both key and
value, eliminating the runtime error and restoring cache functionality.
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