Class InfinispanChatMemoryStore
- All Implemented Interfaces:
ChatMemoryStore
ChatMemoryStore backed by an Infinispan cache.
Messages are serialized to JSON using ChatMessageSerializer and stored as strings,
following the same approach as the other ChatMemoryStore implementations (Coherence, Cassandra, Oracle).
The cache uses application/x-protostream encoding since strings are a native ProtoStream type.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInfinispanChatMemoryStore(org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder, String cacheName, boolean createCache, String cacheConfig) Creates an InfinispanChatMemoryStore from a ConfigurationBuilder.InfinispanChatMemoryStore(org.infinispan.client.hotrod.RemoteCacheManager remoteCacheManager, String cacheName, boolean createCache, String cacheConfig) Creates an InfinispanChatMemoryStore from a pre-configured RemoteCacheManager. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voiddeleteMessages(Object memoryId) Deletes all messages for a specified chat memory.deleteMessagesAsync(Object memoryId) Non-blocking counterpart ofChatMemoryStore.deleteMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.getMessages(Object memoryId) Retrieves messages for a specified chat memory.getMessagesAsync(Object memoryId) Non-blocking counterpart ofChatMemoryStore.getMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.voidupdateMessages(Object memoryId, List<ChatMessage> messages) Updates messages for a specified chat memory.updateMessagesAsync(Object memoryId, List<ChatMessage> messages) Non-blocking counterpart ofChatMemoryStore.updateMessages(Object, List), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.
-
Field Details
-
DEFAULT_CACHE_NAME
- See Also:
-
-
Constructor Details
-
InfinispanChatMemoryStore
public InfinispanChatMemoryStore(org.infinispan.client.hotrod.RemoteCacheManager remoteCacheManager, String cacheName, boolean createCache, String cacheConfig) Creates an InfinispanChatMemoryStore from a pre-configured RemoteCacheManager.- Parameters:
remoteCacheManager- the already configured remote cache managercacheName- the cache name to usecreateCache- whether to create the cache if it doesn't exist. Whenfalse, the cache must already exist on the servercacheConfig- optional custom cache configuration XML
-
InfinispanChatMemoryStore
public InfinispanChatMemoryStore(org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder, String cacheName, boolean createCache, String cacheConfig) Creates an InfinispanChatMemoryStore from a ConfigurationBuilder.- Parameters:
builder- the Infinispan configuration buildercacheName- the cache name to usecreateCache- whether to create the cache if it doesn't exist. Whenfalse, the cache must already exist on the servercacheConfig- optional custom cache configuration XML
-
-
Method Details
-
getMessages
Description copied from interface:ChatMemoryStoreRetrieves messages for a specified chat memory.- Specified by:
getMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.- Returns:
- List of messages for the specified chat memory. Must not be null. Can be deserialized from JSON using
ChatMessageDeserializer.
-
updateMessages
Description copied from interface:ChatMemoryStoreUpdates messages for a specified chat memory.- Specified by:
updateMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.messages- List of messages for the specified chat memory, that represent the current state of theChatMemory. Can be serialized to JSON usingChatMessageSerializer.
-
deleteMessages
Description copied from interface:ChatMemoryStoreDeletes all messages for a specified chat memory.- Specified by:
deleteMessagesin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.
-
getMessagesAsync
Description copied from interface:ChatMemoryStoreNon-blocking counterpart ofChatMemoryStore.getMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException: a store backed by blocking I/O is not silently offloaded to a worker thread, because that would hide the fact that it is not truly non-blocking. Implement this method to return the messages without blocking the calling thread (e.g. using a reactive client), or, if the underlying client is blocking, offload it to an executor explicitly.An implementation must not throw and must not return
null: every failure, including an invalid argument, completes the returned future exceptionally.- Specified by:
getMessagesAsyncin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.- Returns:
- A future that completes with the list of messages for the specified chat memory. Must not be null.
-
updateMessagesAsync
Description copied from interface:ChatMemoryStoreNon-blocking counterpart ofChatMemoryStore.updateMessages(Object, List), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException; seeChatMemoryStore.getMessagesAsync(Object)for the rationale.An implementation must not throw and must not return
null: every failure, including an invalid argument, completes the returned future exceptionally.- Specified by:
updateMessagesAsyncin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.messages- List of messages for the specified chat memory, that represent the current state of theChatMemory.- Returns:
- A future that completes when the messages have been stored.
-
deleteMessagesAsync
Description copied from interface:ChatMemoryStoreNon-blocking counterpart ofChatMemoryStore.deleteMessages(Object), used by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service APIs.The default implementation returns a failed future carrying
AsyncNotSupportedException; seeChatMemoryStore.getMessagesAsync(Object)for the rationale.An implementation must not throw and must not return
null: every failure, including an invalid argument, completes the returned future exceptionally.- Specified by:
deleteMessagesAsyncin interfaceChatMemoryStore- Parameters:
memoryId- The ID of the chat memory.- Returns:
- A future that completes when the messages have been deleted.
-
builder
-