Class CacheHit

java.lang.Object
com.redis.vl.extensions.cache.CacheHit

public class CacheHit extends Object
Represents a cache hit from SemanticCache. Contains the matched response and metadata about the match.
  • Constructor Details

    • CacheHit

      public CacheHit(String prompt, String response, float distance, Map<String,Object> metadata)
      Creates a new CacheHit.
      Parameters:
      prompt - The original prompt that was matched
      response - The cached response
      distance - The vector distance from the query
      metadata - Additional metadata stored with the cache entry
  • Method Details

    • getPrompt

      public String getPrompt()
      Get the matched prompt.
      Returns:
      The prompt
    • getResponse

      public String getResponse()
      Get the cached response.
      Returns:
      The response
    • getDistance

      public float getDistance()
      Get the vector distance.
      Returns:
      The distance (0 = exact match, higher = less similar)
    • getMetadata

      public Map<String,Object> getMetadata()
      Get the metadata.
      Returns:
      An unmodifiable view of the metadata map
    • toString

      public String toString()
      Overrides:
      toString in class Object