# NCACHE.STATS

> Report entries, hits, misses, evictions, memory and savings for a negative cache namespace.

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

```
NCACHE.STATS namespace
```

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

The negative cache holds negative results, such as "user not found" or "refused by moderation", usually with a short TTL, so repeated lookups for the same missing or refused item do not reach your backend or model again. `NCACHE.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 found a live entry. |
| `misses` | Integer | Lookups that found nothing or an expired entry. |
| `evictions` | Integer | Entries removed to make room or because they expired. |
| `memory_bytes` | Integer | Approximate memory used by the entries. |
| `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. |

The `usage_saved_*` fields only grow for entries stored with the usage
options of [NCACHE.SET](https://docs.hotkv.com/commands/ncache-set/index.md).

Errors:

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

## Examples

```
127.0.0.1:6379> NCACHE.STATS lookups
 1) "entries"
 2) (integer) 2
 3) "hits"
 4) (integer) 5
 5) "misses"
 6) (integer) 1
 7) "evictions"
 8) (integer) 0
 9) "memory_bytes"
10) (integer) 190
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"
```

The memory figure depends on your data.

## Compatibility

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

## See also

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