Specifying Consistency Policies
To specify a consistency policy, you use one of the static instances of the Consistency
class, or one of its nested classes.
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 KVStoreConfig.setConsistency()
method. 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 ReadOption
class instance you provide to the TableAPI
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.
package kvstore.basicExample;
import oracle.kv.Consistency;
import oracle.kv.KVStore;
import oracle.kv.KVStoreConfig;
import oracle.kv.KVStoreFactory;
...
KVStoreConfig kconfig = new KVStoreConfig("exampleStore",
"node1.example.org:5088, node2.example.org:4129");
kconfig.setConsistency(Consistency.NONE_REQUIRED);
KVStore kvstore = KVStoreFactory.getStore(kconfig);