@InterfaceStability.Experimental @InterfaceAudience.Public public class TransparentReplicaGetHelper extends Object
TransparentReplicaGetHelper
abstracts common logic to first grab the
active document and if that fails tries all available replicas and returns the first
result.
NOTE: Using these APIs is eventually consistent meaning that you cannot rely on
a previous successful mutation to a document be reflected in the result. Use this
API only if you favor availability over consistency on the read path.Constructor and Description |
---|
TransparentReplicaGetHelper() |
Modifier and Type | Method and Description |
---|---|
rx.Single<JsonDocument> |
getFirstPrimaryOrReplica(String id,
Bucket bucket)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (using the
environments KV timeout for both primary and replica).
|
rx.Single<JsonDocument> |
getFirstPrimaryOrReplica(String id,
Bucket bucket,
long timeout)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (with a custom
timeout value applied to both primary and replica).
|
rx.Single<JsonDocument> |
getFirstPrimaryOrReplica(String id,
Bucket bucket,
long primaryTimeout,
long replicaTimeout)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (with custom
primary and replica timeout values).
|
static <D extends Document<?>> |
getFirstPrimaryOrReplica(String id,
Class<D> target,
Bucket bucket)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (using the
environments KV timeout for both primary and replica).
|
static <D extends Document<?>> |
getFirstPrimaryOrReplica(String id,
Class<D> target,
Bucket bucket,
long timeout)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them (with a custom
timeout value applied to both primary and replica).
|
static <D extends Document<?>> |
getFirstPrimaryOrReplica(String id,
Class<D> target,
Bucket bucket,
long primaryTimeout,
long replicaTimeout)
Asynchronously fetch the document from the primary and if that operations fails try
all the replicas and return the first document that comes back from them.
|
@InterfaceStability.Experimental @InterfaceAudience.Public public rx.Single<JsonDocument> getFirstPrimaryOrReplica(String id, Bucket bucket, long primaryTimeout, long replicaTimeout)
id
- the document ID to fetch.bucket
- the bucket to use when fetching the doc.primaryTimeout
- the timeout to use in MS when fetching the primary.replicaTimeout
- the timeout to use in MS when subsequently fetching the replicas and primary.Single
with either 0 or 1 JsonDocument
.@InterfaceStability.Experimental @InterfaceAudience.Public public rx.Single<JsonDocument> getFirstPrimaryOrReplica(String id, Bucket bucket, long timeout)
id
- the document ID to fetch.bucket
- the bucket to use when fetching the doc.timeout
- the timeout to use for both primary and replica fetches (separately)Single
with either 0 or 1 JsonDocument
.@InterfaceStability.Experimental @InterfaceAudience.Public public rx.Single<JsonDocument> getFirstPrimaryOrReplica(String id, Bucket bucket)
id
- the document ID to fetch.bucket
- the bucket to use when fetching the doc.Single
with either 0 or 1 JsonDocument
.@InterfaceStability.Experimental @InterfaceAudience.Public public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica(String id, Class<D> target, Bucket bucket)
id
- the document ID to fetch.target
- the custom document type to use.bucket
- the bucket to use when fetching the doc.Single
with either 0 or 1 Document
.@InterfaceStability.Experimental @InterfaceAudience.Public public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica(String id, Class<D> target, Bucket bucket, long timeout)
id
- the document ID to fetch.target
- the custom document type to use.bucket
- the bucket to use when fetching the doc.timeout
- the timeout to use for both primary and replica fetches (separately)Single
with either 0 or 1 Document
.@InterfaceStability.Experimental @InterfaceAudience.Public public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica(String id, Class<D> target, Bucket bucket, long primaryTimeout, long replicaTimeout)
id
- the document ID to fetch.target
- the custom document type to use.bucket
- the bucket to use when fetching the doc.primaryTimeout
- the timeout to use in MS when fetching the primary.replicaTimeout
- the timeout to use in MS when subsequently fetching the replicas and primary.Single
with either 0 or 1 Document
.Copyright © 2015 Couchbase, Inc.