For those who don't know MongoDB, it's an open-source document oriented NoSQL database developped by 10Gen. You can more information about it on http://www.mongodb.org/.
The question you have right now, it probably, how to use it cool cache store ? Simple, as for the other cache store you have to add a loader in your Infinispan configuration file.
Here is an exemple:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<loaders> | |
<mongodbStore xmlns="urn:infinispan:config:mongodb:5.3" > | |
<connection host="localhost" port="27017" timeout="2000" acknowledgment="0"/> | |
<authentication username="mongoUser" password="mongoPass" /> | |
<storage database="infinispan_test_database" collection="infispan_cachestore" /> | |
</mongodbStore> | |
</loaders> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConfigurationBuilder b = new ConfigurationBuilder(); | |
b.loaders().addStore(MongoDBCacheStoreConfigurationBuilder.class) | |
.host( "localhost" ) | |
.port( 27017 ) | |
.timeout( 1500 ) | |
.acknowledgment( 0 ) | |
.username( "mongoDBUSer" ) | |
.password( "mongoBDPassword" ) | |
.database( "infinispan_cachestore" ) | |
.collection( "entries" ); | |
final Configuration config = b.build(); | |
MongoDBCacheStoreConfiguration store = (MongoDBCacheStoreConfiguration) config.loaders().cacheLoaders().get(0); |
For more information about the configuration possibilities (default values, options, etc) , you can refer to the documentation page
Cheers,
Guillaume
Hibernate OGM & Infinispan contributor
Blog / @g_scheibel
Please share sample working project
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis will not work, try infinispan.version 8.2.0.Final and infinispan.cachestore.mongodb.version 8.2.0.Final are working together.
ReplyDelete