RetrievalCache
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RetrievalCache(config?): RetrievalCache;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
Returns
Section titled “Returns”RetrievalCache
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size(): number;Total number of cached items (query entries + doc entries).
Returns
Section titled “Returns”number
Methods
Section titled “Methods”clear()
Section titled “clear()”clear(): void;Remove all entries from the cache.
Returns
Section titled “Returns”void
lookup()
Section titled “lookup()”lookup(queryEmbedding, topK?): RetrievalResult[];Look up cached results by query embedding similarity.
First checks the query index (query-to-query similarity, high accuracy with asymmetric models). Falls back to the document index if no query-level match is found.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
readonly |
|
The query’s embedding vector. |
|
|
|
|
Maximum number of results to return. Default: 5. |
Returns
Section titled “Returns”Matching cached results, or empty array on cache miss.
populate()
Section titled “populate()”populate(results, queryEmbedding?): void;Populate the cache with retrieval results and the query embedding that produced them.
When queryEmbedding is provided, stores a query-indexed entry
(preferred for lookup — query-to-query similarity is high).
Also stores individual document embeddings in the document index for results that have them.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
|
|
|
|
|
readonly |
Returns
Section titled “Returns”void