Collections
Vectors are grouped into named collections. A collection is a regular Cache-Pot key whose type isvector. 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
| Command | Description |
|---|---|
VSET key id f1 f2 ... fn [META text] | Insert or overwrite the vector id in collection key. The dimension is fixed by the first insert. |
VSEARCH key f1 ... fn [TOPK k] [WITHSCORES] | Return the top-k nearest neighbours by cosine similarity (default k = 10). Each result includes the ID and META string; add WITHSCORES to include the cosine score. |
VDEL key id | Delete the vector with the given ID from the collection. |
VCARD key | Return the number of vectors stored in the collection. |
VDIM key | Return the vector dimension of the collection. |
Example workflow — document similarity search
Store document embeddings
Insert vectors with descriptive metadata. This example uses 4-dimensional vectors for readability; real embeddings typically have 768–3072 dimensions.
Using with an embedding model
In a real application, you convert text to vectors using an embedding model before callingVSET or VSEARCH. The example below uses the openai Python library with Cache-Pot’s standard Redis wire protocol.
Cosine similarity scoring
The score returned byVSEARCH is the cosine similarity between the query vector and each stored vector, in the range [-1, 1]:
| Score | Meaning |
|---|---|
1.0 | Vectors point in exactly the same direction |
0.9+ | Very high similarity — nearly identical semantic content |
0.7–0.9 | Moderate similarity — related topic |
< 0.7 | Low similarity — probably unrelated |
Vector search uses flat (brute-force) cosine similarity — every vector in the collection is compared against the query. This is optimal for collections up to ~100 K vectors. An HNSW approximate-nearest-neighbour index is planned for a future release.