Este conteúdo não está disponível no idioma selecionado.

19.9. Cassandra Cache Store


Red Hat JBoss Data Grid allows Apache Cassandra to function as a Cache Store, leveraging their distributed database architecture to provide a virtually unlimited, horizontally scalable persistent store for cache entries.
In order to use the Cassandra Cache Store an appropriate keyspace must first be created on the Cassandra database. This may either be performed automatically or by enabling the auto-create-keyspace parameter in the cache store configuration. A sample keyspace creation is demonstrated below:
CREATE KEYSPACE IF NOT EXISTS Infinispan WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
CREATE TABLE Infinispan.InfinispanEntries (key blob PRIMARY KEY, value blob, metadata blob);
Copy to Clipboard Toggle word wrap

19.9.1. Enabling the Cassandra Cache Store

The Cassandra Cache Store is included based on the downloaded distribution. The following indicates where this is located, and steps to enable it if required:
  • Library Mode - The infinispan-cachestore-cassandra-8.3.0.final-redhat-1-deployable.jar is included in the jboss-datagrid-${jdg-version}-library/ directory, and may be added to any projects that are using the Cassandra Cache Store.
  • Remote Client-Server Mode - The Cassandra Cache Store is prepackaged in the modules/ directory of the server, and may be used by default with no additional configuration necessary.
  • JBoss Data Grid modules for JBoss EAP - The Cassandra Cache Store is included in the modules distributed, and may be added by using the org.infinispan.persistence.cassandra as the module name.

19.9.2. Cassandra Cache Store Sample XML Configuration (Remote Client-Server Mode)

In Remote Client-Server mode the Cassandra Cache Store is defined by using the class org.infinispan.persistence.cassandra.CassandraStore and defining the properties individually within the store.
The following configuration snippet provides an example on how to define a Cassandra Cache Store inside of an xml file:
<local-cache name="cassandracache" start="EAGER">
    <locking acquire-timeout="30000" concurrency-level="1000" striping="false"/>
    <transaction mode="NONE"/>
    <store name="cassstore1" 
           class="org.infinispan.persistence.cassandra.CassandraStore" 
           shared="true" 
           passivation="false">
        <property name="autoCreateKeyspace">true</property>
        <property name="keyspace">store1</property>
        <property name="entryTable">entries1</property>
        <property name="consistencyLevel">LOCAL_ONE</property>
        <property name="serialConsistencyLevel">SERIAL</property>
        <property name="servers">127.0.0.1[9042],127.0.0.1[9041]</property>
        <property name="connectionPool.heartbeatIntervalSeconds">30</property>
        <property name="connectionPool.idleTimeoutSeconds">120</property>
        <property name="connectionPool.poolTimeoutMillis">5</property>
    </store>
</local-cache>
Copy to Clipboard Toggle word wrap

19.9.3. Cassandra Cache Store Sample XML Configuration (Library Mode)

In Library Mode the Cassandra Cache Store may be configured using two different methods:
  • Option 1: Using the same method discussed for Remote Client-Server Mode, found in Section 19.9.2, “Cassandra Cache Store Sample XML Configuration (Remote Client-Server Mode)”.
  • Option 2: Using the cassandra-store schema. The following snippet shows an example configuration defining a Cassandra Cache Store:
    <cache-container default-cache="cassandracache">
      <local-cache name="cassandracache">
        <persistence passivation="false">
          <cassandra-store xmlns="urn:infinispan:config:store:cassandra:8.2" 
                auto-create-keyspace="true" 
                keyspace="Infinispan" 
                entry-table="InfinispanEntries" shared="true">
            <cassandra-server host="127.0.0.1" port="9042" />
            <connection-pool heartbeat-interval-seconds="30" 
                idle-timeout-seconds="120" 
                pool-timeout-millis="5" />
          </cassandra-store>
        </persistence>
      </local-cache>
    </cache-container>
    Copy to Clipboard Toggle word wrap

19.9.4. Cassandra Configuration Parameters

When defining a backing Cassandra instance in Library Mode one or more cassandra-server elements may be specified in the configuration. Each of the elements has the following properties:
Expand
Table 19.1. Cassandra Server Configuration Parameters
Parameter Name Description Default Value
host The hostname or ip address of a Cassandra server. 127.0.0.1
port The port on which the server is listening. 9042
The following properties may be configured on the Cassandra Cache Store:
Expand
Table 19.2. Cassandra Configuration Parameter
Parameter Name Description Default Value
auto-create-keyspace Determines whether the keyspace and entry table should be automatically created on startup. true
keyspace Name of the keyspace to use. Infinispan
entry-table Name of the table storing entries. InfinispanEntries
consistency-level Consistency level to use for the queries. LOCAL_ONE
serial-consistency-level Serial consistency level to use for the queries. SERIAL
A connection-pool may also be defined with the following elements:
Expand
Table 19.3. Connection Pool Configuration Parameters
Parameter Name Description Default Value
pool-timeout-millis Time that the driver blocks when no connection from hosts pool is available. After this timeout, the driver will try the next host. 5
heartbeat-interval-seconds Application-side heartbeat to avoid the connections being dropped when no activity is happening. Set to 0 to disable. 30
idle-timeout-seconds Timeout before an idle connection is removed. 120
Voltar ao topo
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2025 Red Hat