Package akka.javasdk.agent
Record Class 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
-
Nested Class Summary
Nested classes/interfaces inherited from interface akka.javasdk.agent.MemoryProvider
MemoryProvider.CustomMemoryProvider, MemoryProvider.Disabled, MemoryProvider.FromConfig, MemoryProvider.LimitedWindowMemoryProvider -
Constructor Summary
ConstructorsConstructorDescriptionLimitedWindowMemoryProvider(Optional<Integer> readLastN, boolean read, boolean write) Creates an instance of aLimitedWindowMemoryProviderrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanread()Returns the value of thereadrecord component.readLast(int onlyLastN) Creates a new memory provider with an updated history limit.Returns the value of thereadLastNrecord component.readOnly()Creates a read-only version of this memory provider.final StringtoString()Returns a string representation of this record class.booleanwrite()Returns the value of thewriterecord component.Creates a write-only version of this memory provider.
-
Constructor Details
-
LimitedWindowMemoryProvider
Creates an instance of aLimitedWindowMemoryProviderrecord class.- Parameters:
readLastN- the value for thereadLastNrecord componentread- the value for thereadrecord componentwrite- the value for thewriterecord component
-
-
Method Details
-
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
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
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
readLastN
Returns the value of thereadLastNrecord component.- Returns:
- the value of the
readLastNrecord component
-
read
public boolean read()Returns the value of thereadrecord component.- Returns:
- the value of the
readrecord component
-
write
public boolean write()Returns the value of thewriterecord component.- Returns:
- the value of the
writerecord component
-