Using Time-Based Consistency

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:

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);