CLIENT TRACKINGINFO
Syntax
CLIENT TRACKINGINFO
Time complexity: O(1)
ACL categories: @connection, @slow
Availability: Dragonfly v2.1.0 and later.
The CLIENT TRACKINGINFO command returns the server-assisted client-side caching state of the current connection:
whether tracking is enabled with CLIENT TRACKING, which options were used,
and whether a CLIENT CACHING override is pending.
Unlike CLIENT TRACKING and CLIENT CACHING, which require RESP3, CLIENT TRACKINGINFO also works on RESP2 connections.
Return
Map reply on RESP3, or a flat Array reply of three field/value pairs on RESP2, with the following fields:
flags: a Set reply (an array on RESP2) of tracking flags:off: tracking is disabled.on: tracking is enabled.optinoroptout: tracking was enabled with theOPTINorOPTOUToption.noloop: tracking was enabled with theNOLOOPoption.caching-yes(withoptin) orcaching-no(withoptout): the one-shot override set byCLIENT CACHING YESorCLIENT CACHING NOis pending.
redirect: an Integer reply,-1when tracking is off and0when it is on.prefixes: an Array reply that is always empty.
Dragonfly does not support the REDIRECT, BCAST and PREFIX options of CLIENT TRACKING.
As a result, redirect never holds a client ID, prefixes never lists a prefix,
and the Valkey flags bcast and broken_redirect never appear.
Passing any argument returns ERR syntax error.
Pending CLIENT CACHING overrides
CLIENT CACHING YES and CLIENT CACHING NO affect only the next command on the connection.
In Dragonfly, CLIENT TRACKINGINFO counts as that command: it reports caching-yes or caching-no and uses up the override.
If you call CLIENT TRACKINGINFO between CLIENT CACHING and the read the override was meant for,
the read is handled according to the plain OPTIN or OPTOUT mode.
Examples
A new connection uses RESP2, so the reply is a flat array. Tracking is off:
dragonfly> CLIENT TRACKINGINFO
1) "flags"
2) 1) "off"
3) "redirect"
4) (integer) -1
5) "prefixes"
6) (empty array)
Switch the connection to RESP3, enable tracking, and check its state.
The id field of the HELLO reply varies between connections.
dragonfly> HELLO 3
1# "server" => "redis"
2# "version" => "7.4.0"
3# "dragonfly_version" => "df-v2.1"
4# "proto" => (integer) 3
5# "id" => (integer) 57
6# "mode" => "standalone"
7# "role" => "master"
dragonfly> CLIENT TRACKING ON
OK
dragonfly> CLIENT TRACKINGINFO
1# "flags" => 1~ "on"
2# "redirect" => (integer) 0
3# "prefixes" => (empty array)
In OPTIN mode, the first CLIENT TRACKINGINFO call after CLIENT CACHING YES reports caching-yes and uses up the override,
so the second call no longer reports it:
dragonfly> HELLO 3
1# "server" => "redis"
2# "version" => "7.4.0"
3# "dragonfly_version" => "df-v2.1"
4# "proto" => (integer) 3
5# "id" => (integer) 58
6# "mode" => "standalone"
7# "role" => "master"
dragonfly> CLIENT TRACKING ON OPTIN
OK
dragonfly> CLIENT CACHING YES
OK
dragonfly> CLIENT TRACKINGINFO
1# "flags" => 1~ "on"
2~ "optin"
3~ "caching-yes"
2# "redirect" => (integer) 0
3# "prefixes" => (empty array)
dragonfly> CLIENT TRACKINGINFO
1# "flags" => 1~ "on"
2~ "optin"
2# "redirect" => (integer) 0
3# "prefixes" => (empty array)