cacheman-mongo
cacheman-mongo copied to clipboard
How to configure for a mongo replication set
when configured with more than one host
such as when passing this type of configuration
{
host: 'db-host-01, db-host-02, db-host-03',
username: 'db-user',
password: 'db-pasword',
database: 'db',
collection: 'cached',
compression: false
}
Any call to set results in a error being raised with this message.
"missing delimiting slash between hosts and options:"
The configuration is identical to the normal mongo configuration (which works) except for the mongo db has an additional option in the config
{
replica: 'replset-name'
}
and when there is more than one host the connection string has to be formed like this:
Expected format - according to Mongo Docs
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
The connection string right now comes out with the wrong format (just a simple concatenation) of the properties and hence the error
wrong format
mongodb://[username:password@]db-host-01, db-host-02, db-host-03[:port1][/[database][?options]]
any thoughts on this ?