Record Class MemoryProvider.LimitedWindowMemoryProvider

Object
Record
akka.javasdk.agent.MemoryProvider.LimitedWindowMemoryProvider
All Implemented Interfaces:
MemoryProvider
Enclosing interface:
MemoryProvider

public static record MemoryProvider.LimitedWindowMemoryProvider(Optional<Integer> readLastN, boolean read, boolean write) extends Record implements MemoryProvider
Memory provider that limits session history based on size or message count.

This provider allows fine-grained control over memory usage by limiting:

  • Use only last N messages from the history
  • Whether reading from memory is enabled
  • Whether writing to memory is enabled
  • Constructor Details

    • LimitedWindowMemoryProvider

      public LimitedWindowMemoryProvider(Optional<Integer> readLastN, boolean read, boolean write)
      Creates an instance of a LimitedWindowMemoryProvider record class.
      Parameters:
      readLastN - the value for the readLastN record component
      read - the value for the read record component
      write - the value for the write record component
  • Method Details

    • readOnly

      public MemoryProvider readOnly()
      Creates a read-only version of this memory provider.

      The returned provider will allow reading from memory but disable writing.

      Returns:
      A new memory provider with writing disabled
    • writeOnly

      public MemoryProvider writeOnly()
      Creates a write-only version of this memory provider.

      The returned provider will allow writing to memory but disable reading.

      Returns:
      A new memory provider with reading disabled
    • readLast

      public MemoryProvider readLast(int onlyLastN)
      Creates a new memory provider with an updated history limit.

      The history limit controls the maximum number of messages to retain in memory.

      Parameters:
      onlyLastN - parameter controls the maximum number of most recent messages to read from memory.
      Returns:
      A new memory provider with the specified history limit
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • readLastN

      public Optional<Integer> readLastN()
      Returns the value of the readLastN record component.
      Returns:
      the value of the readLastN record component
    • read

      public boolean read()
      Returns the value of the read record component.
      Returns:
      the value of the read record component
    • write

      public boolean write()
      Returns the value of the write record component.
      Returns:
      the value of the write record component