Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
system-design-primer
Commits
a70a8f3a
Commit
a70a8f3a
authored
Apr 26, 2018
by
Anton Hulikau
Committed by
Donne Martin
Apr 25, 2018
Browse files
Fix dict KeyError (#153)
parent
e50e2007
Changes
1
Hide whitespace changes
Inline
Side-by-side
solutions/object_oriented_design/lru_cache/lru_cache.py
View file @
a70a8f3a
...
...
@@ -34,7 +34,7 @@ class Cache(object):
Accessing a node updates its position to the front of the LRU list.
"""
node
=
self
.
lookup
[
query
]
node
=
self
.
lookup
.
get
(
query
)
if
node
is
None
:
return
None
self
.
linked_list
.
move_to_front
(
node
)
...
...
@@ -47,7 +47,7 @@ class Cache(object):
If the entry is new and the cache is at capacity, removes the oldest entry
before the new entry is added.
"""
node
=
self
.
lookup
[
query
]
node
=
self
.
lookup
.
get
(
query
)
if
node
is
not
None
:
# Key exists in cache, update the value
node
.
results
=
results
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment