How it works
Store a response
Call
SCACHE.SET with the original prompt, the LLM response, and an optional TTL. Cache-Pot sends the prompt to your configured embeddings endpoint and stores the resulting vector in an internal collection (__scache__).Embed the incoming query
When your app calls
SCACHE.GET, Cache-Pot embeds the incoming prompt using the same embeddings endpoint and queries the __scache__ collection for the nearest neighbour.Threshold check
Cache-Pot compares the cosine similarity score of the best match against the threshold (default
0.90). If the score meets or exceeds the threshold, it returns the cached response.Hit and miss counts are tracked and exposed via
INFO and the built-in dashboard at http://localhost:8080. Every hit is a model call you didn’t pay for.Requirements
Before using semantic cache commands, configure an OpenAI-compatible embeddings endpoint:| Environment variable | Required | Description |
|---|---|---|
CACHEPOT_EMBED_URL | Yes | Base URL of your embeddings endpoint (e.g. https://api.openai.com/v1/embeddings). |
CACHEPOT_EMBED_KEY | If needed | API key for the endpoint. |
CACHEPOT_EMBED_MODEL | No | Model name to request (default: text-embedding-3-small). |
Basic usage
Adjusting the similarity threshold
The default threshold is0.90 (90% cosine similarity). Lower the threshold to match more loosely-worded queries; raise it to require near-identical phrasing.
Dollar-savings example
Persistence
Semantic cache entries are stored in the same keyspace as all other data. They survive restarts through the normal snapshot and AOF mechanisms — Cache-Pot logs aSCACHE.SET as its resulting VSET command in the AOF, so replay never re-calls the embeddings endpoint.
The internal collection
__scache__ is a regular vector collection. You can inspect it with VCARD __scache__ and VDIM __scache__, and it respects all standard TTL and persistence behaviour.