The MongoDB cache store persists data in MongoDB. To communicate with the MongoDB server instance, we are using the official java driver version 3.0.4 To configure the cache store, you just need to add a new entry into the persistence section.

Sample usage

Here is an example for your xml configuration file:

   <mongodbStore xmlns="urn:infinispan:config:mongodb:8.2" >
        <connection uri="mongodb://mongoUser:mongoPass@server1:27017,server2:27017/database?w=0&amp;connectTimeoutMS=2000" collection="infispan_cachestore"/>

If you prefer the programmatic API here is a snippet:

ConfigurationBuilder b = new ConfigurationBuilder();
   .connectionURI( "mongodb://localhost" )
   .collection( "indexes" );

final Configuration config =;

The connection section contains the connection information to connect to the MongoDB server instance. The authentication section is optional, it allows you to specify username and password if you are using some. The storage section explicits where you will store the data.

property usage default value


The MongoDB connection string.



The collection which will contain the elements.