feat: add duplicate() method to RedisSentinel#3212
Open
claygeo wants to merge 2 commits intoredis:masterfrom
Open
feat: add duplicate() method to RedisSentinel#3212claygeo wants to merge 2 commits intoredis:masterfrom
claygeo wants to merge 2 commits intoredis:masterfrom
Conversation
RedisClient and RedisCluster both expose a duplicate() method that creates a new instance with the same options (plus optional overrides). RedisSentinel is missing this method, which forces users to manually reconstruct the sentinel configuration when they need a second connection (e.g., for pub/sub alongside regular commands). Adds duplicate() to the RedisSentinel class following the exact same pattern used by RedisClient and RedisCluster: - Creates a new instance via Object.getPrototypeOf(this).constructor - Spreads existing options + commandOptions + overrides - Returns the correctly typed RedisSentinelType Closes redis#3107
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
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.

Problem
RedisClientTypeandRedisClusterTypeboth expose aduplicate()method for creating a new connection with the same configuration (plus optional overrides).RedisSentinelTypeis missing this method, forcing users to manually reconstruct the full sentinel configuration when they need a second connection.Common use case: pub/sub requires a dedicated connection, so users need to duplicate their sentinel connection:
Solution
Add
duplicate()to theRedisSentinelclass following the exact same pattern used byRedisClient(client/index.ts:1028) andRedisCluster(cluster/index.ts):The duplicated instance is not connected. Users call
.connect()on it, same as withRedisClient.duplicate().Changes
packages/client/lib/sentinel/index.ts-- Addedduplicate()method toRedisSentinelclassBackwards Compatibility
Additive only. No existing methods or types are changed.
Closes #3107
Note
Low Risk
Low risk additive change that mirrors existing
duplicate()implementations onRedisClient/RedisClusterand does not alter connection or command execution paths.Overview
Adds
RedisSentinel.duplicate()to instantiate a new sentinel client using the current instance’s stored#optionsand#commandOptions, with optional overrides, matching theduplicate()behavior already available onRedisClientandRedisCluster.Written by Cursor Bugbot for commit 1135895. This will update automatically on new commits. Configure here.