Skip to content
Code Recycle

Component · for humans & their agents

Embedding Cache

verified · first-partyactively maintained$0 during beta (was $29)

Cache an embedding on the query alone and a model upgrade quietly serves you last month's vectors. A query-embedding cache keyed on the normalised text and the model that produced it, with a TTL and a bound.

by Code Recycle

Get it free — beta

Every claim on this page is refundable if it is untrue — refund policy.

Building it yourself: ~0.7h of agent time across about 2 attempts. Your credits are already paid for, so that feels free — but they are rivalrous: those are hours not spent on the part only you can build. And this one fails quietly when it is wrong, so the attempt that looks finished may not be. $29.

9 tests. Pure, no dependencies, ESM. You supply the embedder.

The bug this exists to prevent

Embedding the same query repeatedly is pure waste, so a cache is obvious. The key is where it goes wrong.

Key on the query string alone and everything works — until you change embedding model. The new model produces vectors in a different space, but the cache still holds the old ones, and it serves them. Search results degrade in a way that looks like a ranking problem, not a caching problem, and the timing does not obviously line up with the deploy because entries expire gradually.

The model is part of the identity of an embedding. Vectors from different models are not comparable, and mixing them is not a small error — it is a search index quietly containing two incompatible coordinate systems.

Rule 2 — normalise carefully, and not too much

The key folds case and surrounding whitespace, because "Paris", "paris " and " PARIS" are the same query and should share a vector.

It deliberately does not strip punctuation or internal spacing. "dog, walk" and "dog walk" are different queries with different embeddings, and over-normalising to raise the hit rate returns the wrong vector — a cache hit that is incorrect is worse than a miss, because a miss costs a call and a wrong hit costs relevance you will investigate elsewhere.

Rule 3 — bounded and expiring

The cache has a TTL and a size bound. An unbounded query cache on a public search endpoint is a memory leak with an attacker-controlled key space: distinct queries are free to generate and each one costs you an entry forever.

What this does NOT do

No embedding — you pass the function. No persistence: it is in-process, so a restart is a cold cache, and a multi-instance deployment has one cache per instance.

No document-embedding cache. This is for queries, which repeat; documents are usually embedded once at ingest and belong in your store.

Verified

9 tests: case and surrounding-whitespace folding, punctuation and internal spacing NOT folded, model separation preventing stale vectors after a switch, compute-once-then-serve, recomputation after TTL, and the size bound.

Not covered: no concurrency test — two simultaneous misses for the same key will both compute, which wastes a call but cannot serve a wrong vector.

01Capabilities

Does

  • + Semantic search
  • + Prompt cache optimization
  • + Cache coherency verification

Doesn’t

  • No exclusions declared

02Requirements & stack

Depends on

No declared dependencies

Credentials needed

None declared

Stack

03Community

No endorsements yet

No verified confirmations yet — be the first.

Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.

Open an issue

Sign in to confirm — weight comes from verified usage, not vote count.

Nobody has reported anything yet — a success counts as a report too.

04Trust Passport

Full passport →
–/100

0/0 automated components pass. An automated score is never a security guarantee.

✓ Verified · first-partyreviewed Sep 20, 2026 · re-verification due Dec 19, 2026
  • publisher identity Publisher status verified; 1 verification(s) on file
  • malicious pattern scan No known malicious-behavior patterns across 7 source file(s) plus listing text
  • capability contract All 0 observed capability reference(s) match the declared manifest
  • agent safety scan No injection patterns in agent-readable content
  • provenance No release signature or provenance attestation
  • behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.

Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.

VersionChannelReleasedNotes
0.1.0stableAug 11, 2026Initial extraction.