# SCACHE.STATS

> Report entries, hits, misses, hit rate, search latency and savings for a semantic cache namespace.

URL: https://docs.hotkv.com/commands/scache-stats/

```
SCACHE.STATS namespace
```

- Group: Semantic cache
- Complexity: O(1)
- HotKV Cloud: Performance and Scale plans
- On-Premise: requires the semantic-cache license feature

The semantic cache returns a cached LLM response when a new query embedding is similar enough to one you stored, so paraphrased requests can hit. Your application computes the embeddings. `SCACHE.STATS` reports counters for one namespace. For a namespace
that does not exist, every counter is zero.

## Return value

The reply is a flat array of alternating field names and values in both RESP2 and RESP3 (it is not sent as a RESP3 map). The fields, in order:

| Field | Type | Meaning |
| --- | --- | --- |
| `entries` | Integer | Entries currently stored. |
| `hits` | Integer | Lookups that returned a response. |
| `misses` | Integer | Lookups that returned nil. |
| `hit_rate` | Bulk string | `hits / (hits + misses)`, or `0`. |
| `p50_us` | Integer | Median search latency in microseconds. |
| `usage_saved_requests` | Integer | Hits on entries that carried usage options. |
| `usage_saved_input_tokens` | Integer | Input tokens those hits did not have to spend. |
| `usage_saved_output_tokens` | Integer | Output tokens those hits did not have to spend. |
| `usage_saved_cache_read_tokens` | Integer | Provider cache-read tokens saved. |
| `usage_saved_cache_write_tokens` | Integer | Provider cache-write tokens saved (5-minute and 1-hour combined). |
| `usage_saved_cost_usd` | Bulk string | Cost saved in US dollars with six decimals, for priced models only. |

Errors:

- `ERR wrong number of arguments for 'scache.stats' command` if the argument count is wrong.
- `NOLICENSE semantic-cache requires a HotKV license. Contact sales@hotkv.com` if your license does not include the `semantic-cache` feature.

## Examples

```
127.0.0.1:6379> SCACHE.STATS small
 1) "entries"
 2) (integer) 2
 3) "hits"
 4) (integer) 3
 5) "misses"
 6) (integer) 1
 7) "hit_rate"
 8) "0.75"
 9) "p50_us"
10) (integer) 10
11) "usage_saved_requests"
12) (integer) 0
13) "usage_saved_input_tokens"
14) (integer) 0
15) "usage_saved_output_tokens"
16) (integer) 0
17) "usage_saved_cache_read_tokens"
18) (integer) 0
19) "usage_saved_cache_write_tokens"
20) (integer) 0
21) "usage_saved_cost_usd"
22) "0.000000"
```

## Compatibility

HotKV-only command. Redis and Valkey have no equivalent.

## See also

[SCACHE.CREATE](https://docs.hotkv.com/commands/scache-create/index.md), [SCACHE.SET](https://docs.hotkv.com/commands/scache-set/index.md), [SCACHE.GET](https://docs.hotkv.com/commands/scache-get/index.md), [SCACHE.FLUSH](https://docs.hotkv.com/commands/scache-flush/index.md), [SCACHE.DROP](https://docs.hotkv.com/commands/scache-drop/index.md), [SCACHE.LIST](https://docs.hotkv.com/commands/scache-list/index.md), [SCACHE.THRESHOLD](https://docs.hotkv.com/commands/scache-threshold/index.md), [AI features guide](https://docs.hotkv.com/ai-features/index.md)