Skip to content

Allow disabling the embeddings cache per request#706

Merged
pushpak1300 merged 1 commit into
0.xfrom
fix-disable-embeddings-cache
Jun 12, 2026
Merged

Allow disabling the embeddings cache per request#706
pushpak1300 merged 1 commit into
0.xfrom
fix-disable-embeddings-cache

Conversation

@pushpak1300

Copy link
Copy Markdown
Member

Currently there's no way to turn off embeddings caching for a single request once it's enabled globally via ai.caching.embeddings.cache. Passing cache: false is silently ignored, and ->cache(0) / ->cache(-1) still return an existing cached entry.

Now an explicit disable wins over the global config:

// global caching is on in config...

// before: still cached
str('hello world')->toEmbeddings(cache: false);
Embeddings::for(['hello'])->cache(0)->generate();

// after: both bypass the cache and hit the provider

Under the hood the request now tracks an explicit cache intent (default to config, or force on/off) instead of inferring it from whether a TTL was set, so a zero/negative TTL means "don't cache" rather than "cache with a 0s TTL". Tests added.

Fixes #691

@pushpak1300 pushpak1300 marked this pull request as ready for review June 12, 2026 16:49
@pushpak1300 pushpak1300 merged commit 9f81b4e into 0.x Jun 12, 2026
12 checks passed
@pushpak1300 pushpak1300 deleted the fix-disable-embeddings-cache branch June 12, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embeddings cache cannot be disabled

1 participant