fix: apply keyPrefix in Redis handler delete methods#1067
Open
JeongGeun wants to merge 4 commits intocaching-tools:canaryfrom
Open
fix: apply keyPrefix in Redis handler delete methods#1067JeongGeun wants to merge 4 commits intocaching-tools:canaryfrom
JeongGeun wants to merge 4 commits intocaching-tools:canaryfrom
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
While studying this repository and learning about cache handlers, I noticed an inconsistency in the handler code. Although not critical for production use, I decided to submit this PR to fix the bug for completeness and consistency.
Summary
Fixed a bug in the
deletemethod of Redis cache handlers wherekeyPrefixwas not being applied to cache keys, causing deletion attempts to target incorrect keys. This brings thedeletemethod implementation in line withgetandsetmethods.Issue
All three Redis handlers had the same bug in their delete method:
redis-strings.tsredis-stack.tsexperimental-redis-cluster.tsWhile the
getandsetmethods correctly usekeyPrefix + key, thedeletemethod was only usingkey, causing it to attempt deletion with an incorrect key.Impact
Low impact in production - Redis handlers use TTL-based auto-eviction (EXAT/EXPIREAT), so expired entries are automatically removed by Redis itself. The
deletemethod is optional and only intended for cache stores that don't support time-based key eviction (see Handler interface documentation).However, this bug prevented manual deletion from working correctly when the
deletemethod was explicitly called with akeyPrefixconfiguration.Changes
keyPrefixto the key parameter in all three Redis handlerdeletemethodsgetandsetmethod implementations