A time-based consistency policy describes the amount of time
that a replica node is allowed to lag behind the master node.
If the replica's data is more than the specified amount of
time out-of-date relative to the master, then a
ConsistencyException
is thrown. In
that event, you can either abandon the operation, retry it
immediately, or pause and then retry it.
In order for this type of a consistency policy to be effective, the clocks on all the nodes in the store must be synchronized using a protocol such as NTP.
In order to specify a time-based consistency policy, you use
the Types.TimeConsistency()
function.
This function
requires the following information:
permissibleLag
The number of milliseconds the replica is allowed to lag behind the master.
timeoutMs
The number of milliseconds
that describes how long the replica is permitted to
wait in an attempt to meet the permissible lag limit.
That is, if the replica cannot immediately meet the
permissible lag requirement, then it will wait this
amount of time to see if it is updated with the
required data from the master. If the replica cannot
meet the permissible lag requirement within the
timeout period, a
ConsistencyException
is
thrown.
The following sets a default time-based consistency policy of 2 seconds. The timeout is 4 seconds.
var nosqldb = require('nosqldb-oraclejs'); // Create a configuration object var configuration = new nosqldb.Configuration(); configuration.proxy.startProxy = false; configuration.proxy.host = 'localhost:7010'; configuration.storeHelperHosts = ['localhost:5000']; configuration.storeName = 'kvstore'; configuration.defaultConsistency = new Types.TimeConsistency(2000, 4000); // Open the store with the specified configuration var store = nosqldb.createStore(configuration);