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
MongoDB
in machine’s root folder. In this example, the directory will be created inC:\Docker
.Navigate to
C:\Docker\MongoDB
and 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\MongoDB
directory 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\MongoDB
directory and execute the command below to startMongoDB
instance.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.config
file 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.dll
MongoDB.Bson.dll
MongoDB.Driver.Core.dll
MongoDB.Driver.dll
MongoDB.Libmongocrypt.dll
In the
appsettings.json.config
file, locateCacheSettings
and 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
}
]
}
]