Cache provider: Cassandra
Overview
This section describes how to create and configure an Apache Cassandra instance running in a Docker container. For more information about Apache Cassandra installations, please navigate to https://cassandra.apache.org/_/quickstart.html/ or follow the steps below:
Installation Prerequisites
You will need to have Docker Desktop for Mac, Docker Desktop for Windows, or similar software installed on your machine.
Create a directory called Cassandra in machine’s root folder. In this example, the directory will be created in C:\Docker.
Navigate to the C:\Docker\Cassandra and create another directory called data. We will be using this directory to store Cassandra data files.
Open VSCode editor and create a new file called docker-compose.yml. This file must be saved within the C:\Docker\Cassandra directory with the following content:
version: "3.9"
services:
cassandra:
image: cassandra:latest
ports:
- 9025:9025
- 9042:9042
- 9160:9160
- 7199:7199
- 9000:9000
- 9001:9001
volumes:
- ./data:/var/lib/cassandra
environment:
- CASSANDRA_CLUSTER_NAME=cass01
In the host machine, launch a command line console within the C:\Docker\Cassandra directory and execute the command below to start the Cassandra instance.
start "Cassandra-DB" docker-compose -f docker-compose.yml up
Realtime API configuration
This section describes how to configure the Realtime API web application to utilize the Apache Cassandra caching mechanism. Please follow the steps below.
Open the appsettings.json.config file in the Realtime API web application.
Ensure the following assemblies are present within the Realtime API web application’s bin directory:
RedPoint.Resonance.CassandraCache.dll
Cassandra.dll
In the appsettings.json.config file, locate CacheSettings and add the following entries:
"Caches": [
{
"Name": "CassandraCache",
"Assembly": "RedPoint.Resonance.CassandraCache",
"Class": "RedPoint.Resonance.CassandraCache.CassandraCacheHandler",
"Settings": [
{
"Key": " Keyspace",
"Value": "REPLACE THIS TEXT WITH CASSANDRA KEYSPACE",
"Key": "Port",
"Value": REPLACE THIS TEXT WITH CASSANDRA PORT NUMBER,
"Key": "ContactPoints",
"Value": “REPLACE THIS TEXT WITH CONTACT POINTS”
}
]
}
]
If running in a clustered Cassandra environment, the Contact Points specified in the ContactPoints setting must be comma-separated.