Cache provider: MongoDB
Overview
This section describes how to create and configure a MongoDB instance running in a Docker container.
Learn more about MongoDB installations.
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
MongoDBin machine’s root folder. In this example, the directory will be created inC:\Docker.Navigate to
C:\Docker\MongoDBand create another directory calleddata. We will be using this directory to store MongoDB data files.Open VSCode editor and create new file called
docker-compose.yml. This file must be saved withinC:\Docker\MongoDBdirectory with the following content:
version: "3.9"
services:
mongo:
image: mongo:latest
ports:
- "27018:27017"
volumes:
- ./data:/data/db
In the host machine, launch command line console within
C:\Docker\MongoDBdirectory and execute the command below to startMongoDBinstance.start " Mongo-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 MongoDB caching mechanism to support RPI realtime decisions. Please follow the steps below.
Open the
appsettings.json.configfile in the Realtime API web application.Ensure you have uploaded the following assemblies to the Realtime API web application’s bin directory:
RedPoint.Resonance.MongoDBCache.dllMongoDB.Bson.dllMongoDB.Driver.Core.dllMongoDB.Driver.dllMongoDB.Libmongocrypt.dll
In the
appsettings.json.configfile, locateCacheSettingsand add the following entries:
"Caches":[
{
"Name":"MongoDBCache",
"Assembly":"RedPoint.Resonance.MongoDBCache",
"Class":" RedPoint.Resonance.MongoDBCache.MongoDBCacheHandler",
"Settings":[
{
"Key":"ConnectionString",
"Value":"REPLACE THIS TEXT WITH MONGODB CONNECTION STRING"
},
{
"Key":" Database",
"Value":"” REPLACE THIS TEXT WITH MONGODB DATABASE NAME”"
},
{
"Key":" CollectionName",
"Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
},
{
"Key":" MessageHistoryCollectionName",
"Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
},
{
"Key":" MessageHistoryCollectionName",
"Value":"REPLACE THIS TEXT WITH MONGODB COLLECTION NAME"
},
{
"Key":"PartitionKeyEnabled",
"Value":false
},
{
"Key":"PartitionKeys",
"Value":[]
},
{
"Key":"IDasKeyEnabled",
"Value":false
}
]
}
]