Class BedrockCacheOptions

java.lang.Object
org.springframework.ai.bedrock.converse.api.BedrockCacheOptions

public class BedrockCacheOptions extends Object
AWS Bedrock cache options for configuring prompt caching behavior.

Prompt caching allows you to reduce latency and costs by reusing previously processed prompt content. Cached content has a fixed 5-minute Time To Live (TTL) that resets with each cache hit.

Example usage:


 BedrockCacheOptions cacheOptions = BedrockCacheOptions.builder()
     .strategy(BedrockCacheStrategy.SYSTEM_ONLY)
     .build();

 ChatResponse response = chatModel.call(new Prompt(
     List.of(new SystemMessage(largeSystemPrompt), new UserMessage("Question")),
     BedrockChatOptions.builder()
         .cacheOptions(cacheOptions)
         .build()
 ));
 
Since:
1.1.0
Author:
Soby Chacko
See Also:
  • Constructor Details

    • BedrockCacheOptions

      public BedrockCacheOptions()
  • Method Details

    • builder

      public static BedrockCacheOptions.Builder builder()
      Creates a new builder for constructing BedrockCacheOptions.
      Returns:
      a new Builder instance
    • getStrategy

      public BedrockCacheStrategy getStrategy()
      Gets the caching strategy.
      Returns:
      the configured BedrockCacheStrategy
    • setStrategy

      public void setStrategy(BedrockCacheStrategy strategy)
      Sets the caching strategy.
      Parameters:
      strategy - the BedrockCacheStrategy to use
    • toString

      public String toString()
      Overrides:
      toString in class Object