Databases 12 min read

Redis 6.0 Client‑Side Caching and Tracking Feature Overview

This article explains Redis 6.0’s new client‑side caching feature, detailing the tracking command, its options such as BCAST, PREFIX, OPTIN, OPTOUT, NOLOOP and REDIRECT, and provides step‑by‑step examples using telnet and redis‑cli to demonstrate how invalidation messages are generated and handled.

Architecture Digest
Architecture Digest
Architecture Digest
Redis 6.0 Client‑Side Caching and Tracking Feature Overview

Redis 6.0 introduces several new features, among which the client‑side caching (tracking) mechanism is a major addition. It allows the server to remember which keys a client has read and to push invalidation messages when those keys change.

The core command is:

CLIENT TRACKING ON|OFF [REDIRECT client-id] [PREFIX prefix] [BCAST] [OPTIN] [OPTOUT] [NOLOOP]

Key options:

REDIRECT : forwards invalidation messages to another client (useful for RESP2 clients).

BCAST : enables broadcast mode, sending invalidations for all keys (or matching prefixes) regardless of whether the client has read them.

PREFIX : in broadcast mode, restricts notifications to keys that start with the given prefix.

OPTIN : only keys read after a CLIENT CACHING YES command are tracked.

OPTOUT : disables tracking for keys read after a CLIENT CACHING OFF command.

NOLOOP : prevents the client that performed the modification from receiving its own invalidation.

Typical workflow:

Start a Redis 6.x server (e.g., redis-server).

Connect with telnet and enable RESP3: hello 3.

Enable tracking: client tracking on (optionally add bcast, prefix, etc.).

Read a key (e.g., get a) to register it.

Modify the key from another client; the tracking client receives an invalidate message.

Examples:

client tracking on
+OK
set a 1
+OK
get a
$1
1

When another client runs set a 2, the tracking client sees:

>2
$10
invalidate
*1
$1
a

Using BCAST with PREFIX a tracks all keys starting with a. Only those keys generate invalidations, while unrelated keys (e.g., feed:...) do not.

With OPTIN, tracking starts only after CLIENT CACHING YES is issued; without it, read‑only keys are not tracked. Conversely, OPTOUT stops tracking after CLIENT CACHING OFF.

The NOLOOP flag suppresses self‑generated invalidations, useful to avoid redundant notifications.

Finally, REDIRECT can forward invalidations to a client that only understands RESP2, by sending them through a Pub/Sub channel such as __redis__:invalidate.

All of these features are implemented in Redis’s tracking.c source file.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redistrackingClient Side CachingRESP3
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.