Class InfinispanChatMemoryStore
java.lang.Object
dev.langchain4j.store.memory.chat.infinispan.InfinispanChatMemoryStore
- All Implemented Interfaces:
ChatMemoryStore
A
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.getMessages(Object memoryId) Retrieves messages for a specified chat memory.voidupdateMessages(Object memoryId, List<ChatMessage> messages) Updates messages for a specified chat memory.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChatMemoryStore
deleteMessagesAsync, getMessagesAsync, updateMessagesAsync
-
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.
-
builder
-