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

    • CacheEligibilityResolver

      public CacheEligibilityResolver(AnthropicCacheStrategy cacheStrategy, Map<org.springframework.ai.chat.messages.MessageType,AnthropicCacheTtl> messageTypeTtl, Map<org.springframework.ai.chat.messages.MessageType,Integer> messageTypeMinContentLengths, Function<@Nullable String,Integer> contentLengthFunction, Set<org.springframework.ai.chat.messages.MessageType> cacheEligibleMessageTypes)
  • Method Details

    • from

      public static CacheEligibilityResolver from(AnthropicCacheOptions cacheOptions)
    • resolve

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

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

      public boolean isCachingEnabled()
    • useCacheBlock

      public void useCacheBlock()