Table of Contents
The KV store is built from some number of computers (generically referred to as nodes) that are working together using a network. All data in your store is first written to a master node. The master node then copies that data to other nodes in the store. Nodes which are not master nodes are referred to as replicas.
Because of the relatively slow performance of distributed systems, there can be a possibility that, at any given moment, a write operation that was performed on the master node will not yet have been performed on some other node in the store.
Consistency, then, is the policy describing whether it is possible for a row on Node A to be different from the same row on Node B.
When there is a high likelihood that a row stored on one node is identical to the same row stored on another node, we say that we have a high consistency guarantee. Likewise, a low consistency guarantee means that there is a good possibility that a row on one node differs in some way from the same row stored on another node.
You can control how high you want your consistency guarantee to be. Note that the trade-off in setting a high consistency guarantee is that your store's read performance might not be as high as if you use a low consistency guarantee.
There are several different forms of consistency guarantees that you can use. They are described in the following sections.
Note that by default, Oracle NoSQL Database uses the lowest possible consistency possible.
To specify a consistency policy, use one of:
Types.SimpleConsistency()
Types.TimeConsistency()
Types.VersionConsistency()
Each of these are described in the following sections.
Once you have selected a consistency policy, you can put it to
use in one of two ways. First, you can use it to define a default
consistency policy using the
Configuration
object
when you open your Store
handle.
Specifying a consistency policy in this way means that all
store operations will use that policy, unless they are
overridden on an operation by operation basis.
The second way to use a consistency policy is to override the
default policy
using a ReadOptions
class instance
you provide to the Store
method
that you are using to perform the store read operation.
The following example shows how to set a default consistency policy for the store. We will show the per-operation method of specifying consistency policies in the following sections.
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.Consistency (
Types.SimpleConsistency.ABSOLUTE
);
// Open the store with the specified configuration
var store = nosqldb.createStore(configuration);