Update query_cache_snippets.py #1140
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed lookup get method from
self.map[query]
toself.lookup.get(query)
Review the Contributing Guidelines
Before submitting a pull request, verify it meets all requirements in the Contributing Guidelines.
Translations
See the Contributing Guidelines. Verify you've:
Fix KeyError and incorrect type hint in Cache class of query_cache_snippets.py
#1094
Description
Replaced direct dictionary access self.lookup[query] with self.lookup.get(query) to prevent KeyError when the query key is missing in the cache.
Fixed all incorrect references to self.map by replacing them with the correctly defined self.lookup dictionary.
Added proper type hints and linked list pointer handling in Node and LinkedList classes for clarity and correctness.
Ensured the Cache class handles missing keys gracefully and correctly manages LRU eviction logic.
Corrected method signatures in Cache.set to align with usage in QueryApi.