Skip to content

Add support for CLIENT GETREDIR command#4550

Open
wushiyuanmaimob wants to merge 1 commit into
redis:masterfrom
wushiyuanmaimob:feature/client-getredir
Open

Add support for CLIENT GETREDIR command#4550
wushiyuanmaimob wants to merge 1 commit into
redis:masterfrom
wushiyuanmaimob:feature/client-getredir

Conversation

@wushiyuanmaimob

@wushiyuanmaimob wushiyuanmaimob commented May 31, 2026

Copy link
Copy Markdown

Closes #2882

Summary

Adds support for the CLIENT GETREDIR command.

The command 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

This complements the existing CLIENT TRACKINGINFO command and is useful for inspecting the active tracking redirection on a connection without having to parse the structured TRACKINGINFO reply.

Changes

  • Added GETREDIR to Protocol.Keyword.
  • Added clientGetredir() to ClientCommands and ClientBinaryCommands interfaces.
  • Implemented clientGetredir() in Jedis.
  • Added integration tests for both the disabled-tracking and redirected-tracking scenarios.

Test plan

  • ClientCommandsTest#clientGetredirWhenTrackingDisabled — verifies that the command returns -1 when tracking has not been enabled.
  • ClientCommandsTest#clientGetredirWithRedirect — verifies that the command returns the configured redirect target's client ID after enabling CLIENT TRACKING ON REDIRECT <id>.

Both tests run across all jedisRespVersions and 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 GETREDIR support so callers can read the client-side caching redirect target as a single integer instead of parsing CLIENT TRACKINGINFO.

GETREDIR is registered on Protocol.Keyword, clientGetredir() is declared on ClientCommands and ClientBinaryCommands, and Jedis sends CLIENT GETREDIR and returns the integer reply. Integration tests cover -1 when tracking is off and the configured redirect client id after CLIENT TRACKING ON REDIRECT.

Reviewed by Cursor Bugbot for commit a6268c4. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@jit-ci

jit-ci Bot commented May 31, 2026

Copy link
Copy Markdown

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.

@ggivo

ggivo commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

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 RedisClient (formerly JedisPooled), which handles CLIENT TRACKING, redirect targets, and invalidations automatically. Have you tried it? If so, what functionality was missing?

I’m asking because the read path on plain Jedis connections does not currently handle invalidte push messages gracefully, so I’d like to better understand the intended use case for CLIENT GETREDIR.

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 CLIENT GETREDIR would solve.
This will help us identify potential gaps in the current CSC solution.

Thanks!

@ggivo ggivo added the waiting-for-feedback We need additional information before we can continue label Jun 1, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

This pull request is marked stale. It will be closed in 30 days if it is not updated.

@github-actions github-actions Bot added the stale label Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale waiting-for-feedback We need additional information before we can continue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for redis command: CLIENT TRACKING

2 participants