CLIENT CACHING
CLIENT CACHING YES | NO
- Group
- Connection
- Complexity
- O(1)
- Arity
- 3 (exactly, counting the command name)
- HotKV Cloud
- All plans
- On-Premise
- no license needed
With CLIENT TRACKING in OPTIN or OPTOUT mode,
the connection decides command by command which keys are tracked. CLIENT CACHING YES turns tracking on for the keys of the next command, in OPTIN mode,
where nothing is tracked otherwise. CLIENT CACHING NO leaves the keys of the
next command out, in OPTOUT mode, where everything is tracked otherwise.
The choice covers the next command only. When it is sent before
MULTI, it covers the commands queued up to EXEC. It can also
be queued inside the transaction.
Return value
Section titled “Return value”Simple string OK, in RESP2 and RESP3.
Errors:
| Error | Cause |
|---|---|
ERR CLIENT CACHING can be called only when the client is in tracking mode with OPTIN or OPTOUT mode enabled |
Tracking is off. |
ERR CLIENT CACHING YES is only valid when tracking is enabled in OPTIN mode. |
YES, with tracking on in another mode. |
ERR CLIENT CACHING NO is only valid when tracking is enabled in OPTOUT mode. |
NO, with tracking on in another mode. |
ERR syntax error |
The argument is neither YES nor NO. |
ERR wrong number of arguments for 'client|caching' command |
The argument is missing or there are more than one. |
Examples
Section titled “Examples”127.0.0.1:6379> CLIENT CACHING YES(error) ERR CLIENT CACHING can be called only when the client is in tracking mode with OPTIN or OPTOUT mode enabled127.0.0.1:6379> CLIENT TRACKING ON OPTINOK127.0.0.1:6379> CLIENT CACHING NO(error) ERR CLIENT CACHING NO is only valid when tracking is enabled in OPTOUT mode.127.0.0.1:6379> CLIENT CACHING YESOK127.0.0.1:6379> CLIENT TRACKINGINFO1) "flags"2) 1) "on" 2) "optin" 3) "caching-yes"3) "redirect"4) (integer) 05) "prefixes"6) (empty array)caching-yes (or caching-no in OPTOUT mode) shows in
CLIENT TRACKINGINFO until the next command has
run.
Compatibility
Section titled “Compatibility”The replies and error texts follow Redis 8 and Valkey 9.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.