Add support for CLIENT GETREDIR command#4550
Conversation
Closes redis#2882 CLIENT GETREDIR returns the client ID we are redirecting our tracking notifications to: - Returns -1 if client tracking is not enabled - Returns 0 if tracking is enabled but not redirecting - Returns the redirect client ID otherwise Adds the method to ClientCommands and ClientBinaryCommands interfaces, and implements it in Jedis. Includes integration tests covering both the disabled-tracking and redirected-tracking scenarios.
|
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. |
|
Hi @wushiyuanmaimob — thanks for the PR! Before we proceed, I have a quick question about the intended use case. Jedis already provides built-in Client-Side Caching via I’m asking because the read path on plain Jedis connections does not currently handle Could you open a short issue describing your use case? It would help us understand what you’re building, where you expect invalidations to be delivered, and what problem adding Thanks! |
|
This pull request is marked stale. It will be closed in 30 days if it is not updated. |
Closes #2882
Summary
Adds support for the
CLIENT GETREDIRcommand.The command returns the client ID we are redirecting our tracking notifications to:
-1if client tracking is not enabled0if tracking is enabled but not redirectingThis complements the existing
CLIENT TRACKINGINFOcommand and is useful for inspecting the active tracking redirection on a connection without having to parse the structuredTRACKINGINFOreply.Changes
GETREDIRtoProtocol.Keyword.clientGetredir()toClientCommandsandClientBinaryCommandsinterfaces.clientGetredir()inJedis.Test plan
ClientCommandsTest#clientGetredirWhenTrackingDisabled— verifies that the command returns-1when tracking has not been enabled.ClientCommandsTest#clientGetredirWithRedirect— verifies that the command returns the configured redirect target's client ID after enablingCLIENT TRACKING ON REDIRECT <id>.Both tests run across all
jedisRespVersionsand pass locally against Redis 7.4.Note
Low Risk
Small, additive CLIENT subcommand wiring with tests; no changes to auth, pooling, or existing command behavior.
Overview
Adds
CLIENT GETREDIRsupport so callers can read the client-side caching redirect target as a single integer instead of parsingCLIENT TRACKINGINFO.GETREDIRis registered onProtocol.Keyword,clientGetredir()is declared onClientCommandsandClientBinaryCommands, andJedissendsCLIENT GETREDIRand returns the integer reply. Integration tests cover-1when tracking is off and the configured redirect client id afterCLIENT TRACKING ON REDIRECT.Reviewed by Cursor Bugbot for commit a6268c4. Bugbot is set up for automated code reviews on this repo. Configure here.