# PCACHE.CONFIG

> Change the entry limit, default TTL or per-hit cost of an existing prompt cache namespace.

URL: https://docs.hotkv.com/commands/pcache-config/

```
PCACHE.CONFIG namespace SET MAX_ENTRIES n
PCACHE.CONFIG namespace SET TTL seconds
PCACHE.CONFIG namespace SET COST_PER_HIT usd
```

- Group: Prompt cache
- Complexity: O(1), or O(N) when lowering MAX_ENTRIES evicts N entries
- HotKV Cloud: Performance and Scale plans
- On-Premise: requires the prompt-cache license feature

The prompt cache is an exact-match cache for LLM prompt and response pairs, organised in named namespaces. `PCACHE.CONFIG` changes one setting of an existing namespace at
runtime. The settings mean the same as in [PCACHE.CREATE](https://docs.hotkv.com/commands/pcache-create/index.md).

## Options

| Option | Effect |
| --- | --- |
| `MAX_ENTRIES n` | New entry limit. `0` uses the server's per-namespace limit, and larger values are capped at it. If the namespace holds more entries than the new limit, the excess is evicted immediately. |
| `TTL seconds` | New default TTL for entries stored afterwards without their own `TTL`. Entries already stored keep their expiry. `0` means no default. |
| `COST_PER_HIT usd` | New per-hit cost used for `cost_saved_usd`. Must be zero or positive. |

The option name is case-insensitive.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Setting changed | Simple string `OK` | Same |

Errors:

- `ERR namespace not found` if the namespace does not exist.
- `ERR invalid MAX_ENTRIES`, `ERR invalid TTL` or `ERR invalid COST_PER_HIT` if the value cannot be parsed or is negative.
- `ERR unknown option` for any other option name.
- `ERR wrong number of arguments for 'pcache.config' command` if the third argument is not `SET` or the argument count is not exactly five.
- `NOLICENSE prompt-cache requires a HotKV license. Contact sales@hotkv.com` if your license does not include the `prompt-cache` feature.

## Examples

```
127.0.0.1:6379> PCACHE.CONFIG llm_prompts SET TTL 7200
OK
127.0.0.1:6379> PCACHE.CONFIG llm_prompts SET COST_PER_HIT 0.02
OK
127.0.0.1:6379> PCACHE.CONFIG missing SET TTL 60
(error) ERR namespace not found
```

## Compatibility

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

## See also

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