Package net.thevpc.naru.api.model
Enum Class NaruCachingMode
- All Implemented Interfaces:
Serializable,Comparable<NaruCachingMode>,Constable
How a provider exposes prompt caching, which determines what a caching client
must do to get a cache hit.
These are genuinely different mechanisms, not variations of one. The mode decides both the wire format and how invalidation is computed, so it is modelled explicitly rather than inferred from the provider name.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe provider caches a literal byte-prefix of the request transparently, with no client-side breakpoint API.The provider accepts inline cache-control breakpoints that the caller places on specific content blocks (Anthropiccache_control).The provider caches context in a separately created, immutable, server-side resource with its own lifecycle and TTL (GeminiCachedContent), referenced by id from generation requests.No caching concept at the API level. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether a cache hit is expressed by the caller sending a marker, as opposed to happening implicitly for a matching prefix.booleanWhether this mode keeps server-side state that must be tracked, expired and eventually deleted.static NaruCachingModeReturns the enum constant of this class with the specified name.static NaruCachingMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NONE
No caching concept at the API level. The full context is re-sent and re-billed every turn. Local providers (Ollama) land here: the server may reuse a KV cache internally per connection, but there is nothing the client can address or rely on. -
AUTOMATIC_PREFIX
The provider caches a literal byte-prefix of the request transparently, with no client-side breakpoint API. NARU's only job is to keep the prefix byte-identical across turns; the provider does the rest. Most OpenAI-compatible backends behave this way.Consequence: because the match is positional, a mid-history edit invalidates everything from the edit point onward even though the segments themselves are unchanged. That cost is inherent to the mechanism, not a defect in NARU.
-
EXPLICIT_INLINE
The provider accepts inline cache-control breakpoints that the caller places on specific content blocks (Anthropiccache_control). NARU decides where the breakpoints go; the request is otherwise unchanged. Each call is stateless, so history mutation needs no server-side state management beyond re-placing the breakpoints. -
EXPLICIT_RESOURCE
The provider caches context in a separately created, immutable, server-side resource with its own lifecycle and TTL (GeminiCachedContent), referenced by id from generation requests.This is the most demanding mode: the resource cannot be patched, so a divergence point that falls inside an already-cached prefix forces the whole resource to be discarded and recreated.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
isClientControlled
public boolean isClientControlled()Whether a cache hit is expressed by the caller sending a marker, as opposed to happening implicitly for a matching prefix. Inline modes must do real work at serialization time; automatic andNONEdo not. -
isStateful
public boolean isStateful()Whether this mode keeps server-side state that must be tracked, expired and eventually deleted. Only resource mode does.
-