Repository navigation
vec-cache@1.2.0
Minor Changes
-
376af3e: Add
findMissing(texts, options), which returns the texts that still need embedding without reading any vectors.Answering "which of these documents do I still need to embed?" used to mean calling
getMany, which copies and decodes a full vector for every hit only for the caller to discard it.findMissingruns the same lookup over each row's key and dimensions only. It returns exactly the listgetOrCreatewould pass toembedfor the same batch: each missing text once, in first-occurrence order, with expired entries and wrong-width hits counted as missing. It takes the same options asgetMany.
Patch Changes
-
0965774:
getOrCreatenow returns every vector, hit or miss, as a typed array in the instance'svectorEncoding.A miss used to come back as whatever
embedreturned, usually a full-precisionnumber[], while a hit came back as a decodedFloat32Array. One result could mix both,JSON.stringifyrendered one as an array and the other as an object, and a text's first call returned different numbers from its later hits. A miss is now converted to the value the cache stored:Float32Arrayby default,Float64ArrayundervectorEncoding: 'float64'. SetvectorEncoding: 'float64'to keep the full precisionembedreturned.getManyalso converts a row written under anothervectorEncodingto the instance's. -
719a52f: Rewriting a cache entry now resets its creation time.
Re-embedding a TTL-expired entry, or calling
setManyover an existing key, used to keep the oldcreated_at_ms.prune({ olderThanMs })could then delete a row that had just been paid for, forcing another embed on the next request, andstats().newestEntryMsdid not reflect the rewrite. An entry's age now counts from its latest write, as itsexpires_at_msalready did.