Cassandra Cache Store
Use Apache Cassandra as the external storage for a GridGain 8 cache with the Cassandra cache store.
GridGain provides a CacheStore implementation that uses Apache Cassandra as the external storage for a cache. The Cassandra cache store does the following:
Reads entries from Cassandra when they are missing in the cache (read-through), and writes cache updates to Cassandra (write-through).
Runs batch operations such as
loadAll(),writeAll(), anddeleteAll()as asynchronous Cassandra queries.Creates the keyspaces and tables it needs in Cassandra.
The cache store connects to Cassandra through the DataStax Java driver 4.17 (com.datastax.oss.driver.*). The driver does not support native protocol versions 1 and 2, so you need Apache Cassandra 2.1 or later.
Enabling the Module
The Cassandra cache store is provided by the ignite-cassandra-store module:
To use it on a node started with the
ignite.shorignite.batscript, move thelibs/optional/ignite-cassandra-storefolder tolibson every server node. For more information, see Enabling Modules.To use it in a Maven project, add the dependency:
<dependency> <groupId>org.gridgain</groupId> <artifactId>ignite-cassandra-store</artifactId> <version>${gridgain.version}</version> </dependency>
To store objects as BLOBs serialized with Kryo, also enable the ignite-cassandra-serializers module.
Configuring the Cache Store
To configure the Cassandra cache store, define three things in the node configuration:
A
DataSourcebean that describes the connection to Cassandra.A
KeyValuePersistenceSettingsbean that describes how cache keys and values map to a Cassandra table.A cache that uses
CassandraCacheStoreFactoryas its cache store factory.
The following example configures the cache1 cache to read and write entries through Cassandra:
CassandraCacheStoreFactory looks up the DataSource and KeyValuePersistenceSettings beans by name in the Spring context of the node. You can also set the objects directly with the dataSource and persistenceSettings properties.
Persistence Settings
The persistence settings file maps the cache keys and values to the columns of a Cassandra table. The following file stores Long keys and values in the key and value columns of the test1.primitive_test1 table:
The keyPersistence and valuePersistence elements support the following strategies:
PRIMITIVE- stores a simple Java type, such asint,long,String,double, orDate, in a column of the matching Cassandra type.BLOB- stores any Java object as a BLOB. Set theserializerattribute toorg.apache.ignite.cache.store.cassandra.serializer.JavaSerializer, or toorg.apache.ignite.cache.store.cassandra.serializer.KryoSerializerfrom theignite-cassandra-serializersmodule.POJO- stores each field of the object in its own column. You can map fields to columns explicitly withfieldelements, and define the partition key and clustering key of the table with thepartitionKeyandclusterKeyelements.
The persistence element also accepts an optional ttl attribute (row expiration, in seconds), and optional keyspaceOptions and tableOptions elements. The cache store uses those options when it creates the keyspace or the table.
Data Source Properties
The DataSource bean supports the following properties.
contactPoints
Comma-separated list of Cassandra hosts. A host can include a port, for example cassandra1.example.com:9142. Required, unless the contact points are set in the driver configuration file.
None
port
The port used for the contact points that do not specify one.
9042
localDataCenter
The name of the local Cassandra datacenter for the default load balancing policy. Required when you set contactPoints, unless you set a custom load balancing policy class or set basic.load-balancing-policy.local-datacenter in the driver configuration. Otherwise, the cache store fails with Cassandra local datacenter is not specified for the data source.
None
user, password
The user name and password for Cassandra authentication. If user is set, password is required.
None
credentials
An object that implements org.apache.ignite.cache.store.cassandra.datasource.Credentials, for example PlainCredentials. Cannot be combined with user and password.
None
authProvider
A DataStax driver AuthProvider instance, for authentication schemes other than user name and password.
None
useSSL
If true, connects to Cassandra over SSL with the default JDK SSLContext.
false
sslEngineFactory
A DataStax driver SslEngineFactory instance, for custom SSL settings such as your own keystore, truststore, or cipher suites.
None
protocolVersion
The native protocol version, for example 4. Versions 1 and 2 are not supported and fail with Incorrect protocol version.
Negotiated by the driver
compression
Transport compression: lz4, snappy, or none.
None
fetchSize
The number of rows to fetch at once when running a CQL statement.
Driver default
readConsistency, writeConsistency
The Cassandra consistency level for read and write operations, for example ONE, QUORUM, or LOCAL_QUORUM.
Driver default
maxSchemaAgreementWaitSeconds
The maximum time, in seconds, to wait for schema agreement after a DDL statement.
Driver default
loadBalancingPolicyClass, reconnectionPolicyClass, retryPolicyClass, addressTranslatorClass, speculativeExecutionPolicyClass
The class of the corresponding driver policy. The class must have a public constructor that takes a DriverContext and a String. The driver creates the instances.
Driver default
configFile
The name of a classpath resource with additional driver configuration, without the .conf extension. See Driver Configuration File.
None
sessionExpirationTimeout
The time, in milliseconds, after which an idle Cassandra session is closed. A new session is created when it is needed. 0 disables the timeout.
300000
The cache store validates the authentication settings when it opens a Cassandra session. If both user/password and credentials are set, it fails with Both 'user'/'password' and 'credentials' are set for the data source.
Driver Configuration File
Driver options that do not have a DataSource property, such as connection pool size, socket options, and Netty settings, go to a driver configuration file. The file uses the HOCON format of the DataStax driver application.conf file, with all options under the datastax-java-driver root.
For example, save the following content as cassandra-driver.conf on the classpath of every server node:
Then reference the file by its name without the extension:
If the file is not found on the classpath or is empty, the cache store fails with Cassandra driver config file is not found on classpath or is empty.
The cache store applies the driver settings in the following order of precedence, from highest to lowest:
Java system properties.
The file set with
configFile.The
DataSourceproperties.The
application.conffile of your application.The cache store defaults: a request timeout of 12 seconds, and a request throttler that runs up to 1024 concurrent requests and queues up to 100000 more.
The driver defaults.
Upgrading from GridGain 8.9.x
GridGain 8.10 moves the Cassandra cache store from the DataStax Java driver 3.2 to 4.17. Review your configuration before you upgrade:
Cassandra version. Cassandra 2.1 or later is required. Setting
protocolVersionto1or2fails withIncorrect protocol version. To upgrade a Cassandra 3 cluster to Cassandra 5, upgrade it to Cassandra 4 first.Local datacenter. Set
localDataCenterif you setcontactPointsand do not use a custom load balancing policy.Policies. Policies are set by class instead of by instance:
GridGain 8.9.x propertyGridGain 8.10 propertyloadBalancingPolicyloadBalancingPolicyClassreconnectionPolicyreconnectionPolicyClassretryPolicyretryPolicyClassaddressTranslatoraddressTranslatorClassspeculativeExecutionPolicyspeculativeExecutionPolicyClasssslOptionssslEngineFactorypoolingOptions,socketOptions,nettyOptionsRemoved. Use
configFileand a Driver Configuration File.collectMetrix,jmxReportingRemoved.
Authentication. Set either
userandpassword, orcredentials, but not both.Dynamically created caches. GridGain 8.10 cannot read a
DataSourceserialized by an earlier version. If a cache that uses the Cassandra cache store was created dynamically, deserialization fails withUnsupported DataSource serialization format version. Drop such caches and create them again after the upgrade.Large transactions. The cache store writes the changes of a transaction to Cassandra as a single logged batch. A large transaction can exceed the
batch_size_fail_thresholdlimit of Cassandra. Keep transactions small, or raise the limit in the Cassandra configuration.
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

