Skip to main content
Cache-Pot includes a native vector store — you can persist float32 embeddings and search by cosine similarity without standing up a separate database. Vector collections live in the same keyspace as all other data types, so they benefit from the same TTL, snapshot, and AOF support you already know. This makes Cache-Pot a single binary that covers both the caching layer and the semantic search layer of an AI application.

Collections

Vectors are grouped into named collections. A collection is a regular Cache-Pot key whose type is vector. Within a collection, every vector must share the same dimension — the dimension is fixed the moment you insert the first vector with VSET, and any subsequent insert with a different number of floats returns an error. Each vector entry has three components:

ID

A unique string identifier within the collection. Re-using an ID overwrites the existing vector.

Float32 array

The vector itself — a space-separated sequence of floating-point values passed directly in the command.

META (optional)

An arbitrary string attached to the vector, such as a document title, URL, or serialised JSON payload.

Commands


1

Store document embeddings

Insert vectors with descriptive metadata. This example uses 4-dimensional vectors for readability; real embeddings typically have 768–3072 dimensions.
2

Search for the most similar document

Pass a query vector and request the top-2 results with scores.
3

Inspect collection stats


Using with an embedding model

In a real application, you convert text to vectors using an embedding model before calling VSET or VSEARCH. The example below uses the openai Python library with Cache-Pot’s standard Redis wire protocol.

Cosine similarity scoring

The score returned by VSEARCH is the cosine similarity between the query vector and each stored vector, in the range [-1, 1]:
Cache-Pot picks the search strategy automatically per collection. Collections up to 256 vectors use exact flat (brute-force) cosine similarity — every vector is compared against the query, so results are always exact. Past that size, an HNSW (Hierarchical Navigable Small World) graph index takes over: query time becomes sub-linear instead of linear, at the cost of approximate rather than exact results. In testing, HNSW returns 100% of the same top-10 neighbours as brute force while running several times faster on collections in the low thousands of vectors — and the speed gap widens as collections grow. VSET, VSEARCH, and every other command behave identically either way.
Vector collections are regular Cache-Pot keys, so you can set a TTL on the whole collection (EXPIRE docs 86400), delete it with DEL docs, check its type with TYPE docs, and scan for it with KEYS *. All standard key operations apply.