# PCACHE.GET

> Look up the cached response for an exact prompt in a prompt cache namespace.

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

```
PCACHE.GET namespace prompt
```

- Group: Prompt cache
- Complexity: O(1)
- 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.GET` returns the cached response for `prompt`, which must
match the stored prompt byte for byte. In an existing namespace, each call
counts as a hit or a miss in
[PCACHE.STATS](https://docs.hotkv.com/commands/pcache-stats/index.md). An expired entry counts as a miss.

Use [PCACHE.GETEX](https://docs.hotkv.com/commands/pcache-getex/index.md) when you also need the entry's metadata and hit
count.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Hit | Bulk string: the cached response | Same |
| Miss, expired entry, or unknown namespace | Nil bulk string | Null |

Errors:

- `ERR wrong number of arguments for 'pcache.get' command` if the argument count is wrong.
- `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.SET llm_prompts "Translate: Hello" "Bonjour"
OK
127.0.0.1:6379> PCACHE.GET llm_prompts "Translate: Hello"
"Bonjour"
127.0.0.1:6379> PCACHE.GET llm_prompts "Translate: Goodbye"
(nil)
```

## 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.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), [PCACHE.CONFIG](https://docs.hotkv.com/commands/pcache-config/index.md), [AI features guide](https://docs.hotkv.com/ai-features/index.md)