Skip to content

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 <[email protected]>
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