Replica reads

class couchbase.replica_reads.GetReplicaStrategy

Selects the replica that get_replica reads from.

Create one with from_index().

static from_index(replica_index: ReplicaIndex, wrap: bool = False) → GetReplicaStrategyFromIndex

Read from the replica at replica_index.

Parameters:
  • replica_index (ReplicaIndex) – The replica to read from.

  • wrap (bool, optional) – When the replica at replica_index cannot be read, because the bucket has fewer replicas or that replica is currently unavailable, read the next one that can be read instead, wrapping around the bucket’s replicas. Defaults to False.

Returns:

The strategy.

Return type:

GetReplicaStrategyFromIndex

Raises:

InvalidArgumentException – If replica_index is not a ReplicaIndex, or wrap is not a bool.

class couchbase.replica_reads.GetReplicaStrategyFromIndex(replica_index: ReplicaIndex, wrap: bool)

Reads from the replica at a given index.

Created by GetReplicaStrategy.from_index().

property replica_index: ReplicaIndex

The replica to read from.

property wrap: bool

Whether to read the next readable replica when this one cannot be read.

class couchbase.replica_reads.ReadPreference(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Which replicas a replica read may read from.

NO_PREFERENCE reads from any replica. SELECTED_SERVER_GROUP reads only from nodes in the server group the preferred_server_group cluster option names.

NO_PREFERENCE = 0
SELECTED_SERVER_GROUP = 1
class couchbase.replica_reads.ReplicaIndex(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

The position of a replica in a document’s replica chain.

FIRST = 0
SECOND = 1
THIRD = 2