You can use pre-defined consistency constants to specify certain rigid consistency guarantees. There are three such instances that you can use:
ABSOLUTE
Requires that the operation be serviced at the master node. In this way, the row(s) will always be consistent with the master.
This is the strongest possible consistency guarantee that you can require, but it comes at the cost of servicing all read and write requests at the master node. If you direct all your traffic to the master node (which is just one machine for each partition), then you will not be distributing your read operations across your replicas. You also will slow your write operations because your master will be busy servicing read requests. For this reason, you should use this consistency guarantee sparingly.
NONE_REQUIRED
Allows the store operation to proceed regardless of the state of the replica relative to the master. This is the most relaxed consistency guarantee that you can require. It allows for the maximum possible store performance, but at the high possibility that your application will be operating on stale or out-of-date information.
NONE_REQUIRED_NO_MASTER
Requires read operations to be serviced on a replica; never the Master. When this policy is used, the read operation will not be performed if the only node available is the Master.
Where possible, this consistency policy should be avoided in favor of the secondary zones feature.
For example, suppose you are performing a critical read operation that you know must absolutely have the most up-to-date data. Then do this:
... ### Store handle configuration and open skipped for brevity def do_store_ops(store): ## Create the simple consistency guarantee to use for this ## store read. ro = ReadOptions({ONDB_CONSISTENCY : ABSOLUTE, ONDB_TIMEOUT : 600}) try: primary_key_d = {"item" : "bolts"} row = store.get("myTable", primary_key_d, ro) if not row: logging.debug("Row retrieval failed") else: logging.debug("Row retrieval succeeded.") display_row(row) except IllegalArgumentException, iae: logging.error("Row retrieval failed.") logging.error(iae.message) return except ConsistencyException, ce: logging.error("Row retrieval failed due to Consistency.") logging.error(ce.message) except RequestTimeoutException, rte: logging.error("Row retrieval failed, exceeded timeout value.") logging.error(rte.message)