liveBook · Manning

CassandraChatMemoryRepository

As explained in Spring AI in Action

CassandraChatMemoryRepository is a Spring AI ChatMemoryRepository implementation that persists chat history in Apache Cassandra.

CassandraChatMemoryRepository is Spring AI’s ChatMemoryRepository implementation for persisting chat history in Apache Cassandra, allowing conversations to survive application restarts. section 5.4.1

Use it by:

  • Adding the Cassandra chat-memory starter dependency. section 5.4.1
  • Injecting the autoconfigured ChatMemoryRepository into a MessageWindowChatMemory bean. section 5.4.1
  • Providing an available Cassandra cluster and, when needed, configuring its keyspace, table, and message-column properties. section 5.4.1
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-repository-cassandra'

Starter dependency for enabling Cassandra-backed chat-memory autoconfiguration. section 5.4.1

@Bean
ChatMemory chatMemory(ChatMemoryRepository chatMemoryRepository) {
  return MessageWindowChatMemory.builder()
      .chatMemoryRepository(chatMemoryRepository)
      .build();
}

Bean configuration connecting MessageWindowChatMemory to the injected repository. section 5.4.1

How Spring AI in Action covers it

How deep it goes
Explains dependency, autoconfiguration, bean wiring, cluster availability, and properties, but not Cassandra internals.
Examples
Uses a Gradle starter, a Spring bean, a Cassandra service, and keyspace, table, and message-column properties.
What it assumes
Assumes a Spring AI application and ChatMemory setup while hiding most Cassandra-specific implementation details through autoconfiguration.
What you can do after
Operate/configure persistent chat memory by wiring Spring AI to an available Cassandra cluster.
How it connects
Connects ChatMemoryRepository with MessageWindowChatMemory, Spring AI autoconfiguration, Apache Cassandra, and Cassandra Query Language.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.