Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

PCACHE.CONFIG

Last updated
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
Arity
5 (exactly, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
Performance and Scale
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.

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.

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.
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

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

PCACHE.CREATE, PCACHE.SET, PCACHE.GET, PCACHE.GETEX, PCACHE.DEL, PCACHE.STATS, PCACHE.FLUSH, PCACHE.DROP, PCACHE.LIST, AI features guide