# CLIENT TRACKINGINFO

> Report the client-side caching state of the connection, with its flags, where invalidations go and its prefixes.

URL: https://docs.hotkv.com/commands/client-trackinginfo/

```
CLIENT TRACKINGINFO
```

- Group: Connection
- Complexity: O(N) where N is the number of prefixes
- HotKV Cloud: all plans
- On-Premise: no license needed

`CLIENT TRACKINGINFO` reports the state that [CLIENT TRACKING](https://docs.hotkv.com/commands/client-tracking/index.md)
gave the current connection. Client libraries read it to check how tracking is set
up before they rely on it.

## Return value

Three fields: a map in RESP3, a flat array of field and value pairs in RESP2.

| Field | Value |
| --- | --- |
| `flags` | A set (an array in RESP2) of strings, see below. |
| `redirect` | `-1` when tracking is off, `0` when invalidations come to this connection, else the id of the connection they go to. |
| `prefixes` | The `BCAST` prefixes, sorted by their bytes. Empty outside `BCAST`. |

The flags:

| Flag | Meaning |
| --- | --- |
| `off` | Tracking is off. It is the only flag then. |
| `on` | Tracking is on. |
| `bcast` | `BCAST` mode. |
| `optin`, `optout` | The mode the connection chose. |
| `caching-yes`, `caching-no` | A [CLIENT CACHING](https://docs.hotkv.com/commands/client-caching/index.md) is waiting for the next command (with `optin` or `optout`). |
| `noloop` | `NOLOOP` was given. |
| `broken_redirect` | The connection redirected to has closed. |

## Examples

Tracking off, on a RESP2 connection:

```
127.0.0.1:6379> CLIENT TRACKINGINFO
1) "flags"
2) 1) "off"
3) "redirect"
4) (integer) -1
5) "prefixes"
6) (empty array)
```

In `OPTOUT` mode, with the next command left out:

```
127.0.0.1:6379> CLIENT TRACKING ON OPTOUT NOLOOP
OK
127.0.0.1:6379> CLIENT CACHING NO
OK
127.0.0.1:6379> CLIENT TRACKINGINFO
1) "flags"
2) 1) "on"
   2) "optout"
   3) "caching-no"
   4) "noloop"
3) "redirect"
4) (integer) 0
5) "prefixes"
6) (empty array)
```

Broadcasting three prefixes, which are listed in byte order whatever order they
were given in:

```
127.0.0.1:6379> CLIENT TRACKING ON BCAST PREFIX user: PREFIX order:
OK
127.0.0.1:6379> CLIENT TRACKING ON BCAST PREFIX cart:
OK
127.0.0.1:6379> CLIENT TRACKINGINFO
1) "flags"
2) 1) "on"
   2) "bcast"
3) "redirect"
4) (integer) 0
5) "prefixes"
6) 1) "cart:"
   2) "order:"
   3) "user:"
```

## Compatibility

The same reply shape, flags and order as Redis 8 and Valkey 9.

## See also

[CLIENT TRACKING](https://docs.hotkv.com/commands/client-tracking/index.md), [CLIENT GETREDIR](https://docs.hotkv.com/commands/client-getredir/index.md),
[CLIENT CACHING](https://docs.hotkv.com/commands/client-caching/index.md), [CLIENT LIST](https://docs.hotkv.com/commands/client-list/index.md)