adk_context_cache (erlang_adk v0.7.0)
View SourceOwner-bound registry for provider-managed model-request prefix caches.
Entries are scoped by application, user, model, policy, provider, prefix, and TTL policy. Concurrent misses for the same key use one provider create operation. Provider resource names remain private behind runtime leases; public results contain only versioned, JSON-safe lifecycle and telemetry metadata. This module never stores or returns a model response.
Summary
Functions
Acquire or create a private prefix-cache lease.
Invalidate all entries and in-flight creates for one provider scope.
Invalidate one provider scope and sanitized prefix, across TTLs.
Invalidate one exact provider scope with an absolute deadline.
Resolve a lease for immediate provider-adapter use.
Return content-free lifecycle counts for one exact provider scope.
Types
-type lease() :: {adk_context_cache_lease, pid(), binary(), pos_integer()}.
-type policy() :: map().
Functions
-spec acquire(pid(), module(), map(), map(), map()) -> {ok, lease(), map()} | {bypass, map()} | {error, term()}.
Acquire or create a private prefix-cache lease.
Scope must contain exactly app, user, model, and policy. Prefix is secret-pruned before hashing or provider delivery. Options are ttl_ms, an absolute monotonic deadline_ms, and optional provider estimated_tokens.
-spec capabilities() -> map().
Invalidate all entries and in-flight creates for one provider scope.
Invalidate one provider scope and sanitized prefix, across TTLs.
Invalidate one exact provider scope with an absolute deadline.
This is intentionally distinct from the compatibility invalidate/3 API so checked administrative callers can fail closed if a queued request reaches the registry after its authorization window has expired.
Resolve a lease for immediate provider-adapter use.
The returned resource name is runtime-private and must never be persisted in events, telemetry, logs, checkpoints, or developer API results.
Return content-free lifecycle counts for one exact provider scope.
Filtering stays inside the private registry. The result never includes a cache pid, lease, provider resource name, prefix, policy value, or credential. deadline_ms is an absolute monotonic deadline and is checked again by the registry before it examines its entries.
-spec stop(pid()) -> ok.
-spec version() -> pos_integer().