Class CacheEligibilityResolver

java.lang.Object
org.springframework.ai.anthropic.CacheEligibilityResolver

public class CacheEligibilityResolver extends Object
Resolves cache eligibility for messages based on the provided AnthropicCacheOptions. Returns SDK CacheControlEphemeral instances instead of raw cache control records.
Since:
1.1.0
Author:
Austin Dase, Soby Chacko
  • Constructor Details

  • Method Details

    • from

      public static CacheEligibilityResolver from(AnthropicCacheOptions cacheOptions)
    • resolve

      public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolve(MessageType messageType, @Nullable String content)
    • resolveToolCacheControl

      public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolveToolCacheControl()
    • resolveCitationDocumentCacheControl

      public @Nullable com.anthropic.models.messages.CacheControlEphemeral resolveCitationDocumentCacheControl()
      Resolves the cache control for citation documents. Documents are stable reference material in the same way as the system prompt, so they receive a breakpoint under every strategy that caches system content, using the SYSTEM TTL. Under AnthropicCacheStrategy.TOOLS_ONLY documents are not cached, because a breakpoint on a document would also cache the system prompt that precedes it.
      Returns:
      the cache control to apply to the last document block, or null if documents are not cached under the current strategy or all breakpoints are used
      Since:
      2.0.2
    • isCachingEnabled

      public boolean isCachingEnabled()
    • useCacheBlock

      public void useCacheBlock()