public class CouchbaseAsyncBucket extends Object implements AsyncBucket
| Modifier and Type | Field and Description |
|---|---|
static BinaryTranscoder |
BINARY_TRANSCODER |
static JsonArrayTranscoder |
JSON_ARRAY_TRANSCODER |
static JsonBooleanTranscoder |
JSON_BOOLEAN_TRANSCODER |
static JsonDoubleTranscoder |
JSON_DOUBLE_TRANSCODER |
static JsonLongTranscoder |
JSON_LONG_TRANSCODER |
static JsonTranscoder |
JSON_OBJECT_TRANSCODER |
static JsonStringTranscoder |
JSON_STRING_TRANSCODER |
static LegacyTranscoder |
LEGACY_TRANSCODER |
static RawJsonTranscoder |
RAW_JSON_TRANSCODER |
static SerializableTranscoder |
SERIALIZABLE_TRANSCODER |
static StringTranscoder |
STRING_TRANSCODER |
| Constructor and Description |
|---|
CouchbaseAsyncBucket(com.couchbase.client.core.ClusterFacade core,
CouchbaseEnvironment environment,
String name,
String password,
List<Transcoder<? extends Document,?>> customTranscoders) |
| Modifier and Type | Method and Description |
|---|---|
<D extends Document<?>> |
append(D document)
Append a
Document to another one. |
Observable<AsyncBucketManager> |
bucketManager()
Provides access to the
AsyncBucketManager for administrative access. |
Observable<Boolean> |
close()
Closes the
AsyncBucket. |
Observable<com.couchbase.client.core.ClusterFacade> |
core()
Returns the underlying “core-io” library through its
ClusterFacade. |
Observable<JsonLongDocument> |
counter(String id,
long delta)
Increment or decrement a counter with the given value and a default value of 0.
|
Observable<JsonLongDocument> |
counter(String id,
long delta,
long initial)
Increment or decrement a counter with the given value and a initial value if it does not exist.
|
Observable<JsonLongDocument> |
counter(String id,
long delta,
long initial,
int expiry)
Increment or decrement a counter with the given value and a initial value if it does not exist.
|
<D extends Document<?>> |
get(D document)
Retrieves any type of
Document by its unique ID. |
Observable<JsonDocument> |
get(String id)
Retrieves a
JsonDocument by its unique ID. |
<D extends Document<?>> |
get(String id,
Class<D> target)
Retrieves any type of
Document by its unique ID. |
<D extends Document<?>> |
getAndLock(D document,
int lockTime)
Retrieve and lock a
Document by its unique ID. |
Observable<JsonDocument> |
getAndLock(String id,
int lockTime)
Retrieve and lock a
JsonDocument by its unique ID. |
<D extends Document<?>> |
getAndLock(String id,
int lockTime,
Class<D> target)
Retrieve and lock a
Document by its unique ID. |
<D extends Document<?>> |
getAndTouch(D document)
Retrieve and touch a
Document by its unique ID. |
Observable<JsonDocument> |
getAndTouch(String id,
int expiry)
Retrieve and touch a
JsonDocument by its unique ID. |
<D extends Document<?>> |
getAndTouch(String id,
int expiry,
Class<D> target)
Retrieve and touch a
Document by its unique ID. |
<D extends Document<?>> |
getFromReplica(D document,
ReplicaMode type)
Retrieves one or more, possibly stale, representations of a
Document by its unique ID. |
Observable<JsonDocument> |
getFromReplica(String id,
ReplicaMode type)
Retrieves one or more, possibly stale, representations of a
JsonDocument by its unique ID. |
<D extends Document<?>> |
getFromReplica(String id,
ReplicaMode type,
Class<D> target)
Retrieves one or more, possibly stale, representations of a
Document by its unique ID. |
<D extends Document<?>> |
insert(D document)
Insert a
Document if it does not exist already. |
<D extends Document<?>> |
insert(D document,
PersistTo persistTo)
Insert a
Document if it does not exist already and watch for durability constraints. |
<D extends Document<?>> |
insert(D document,
PersistTo persistTo,
ReplicateTo replicateTo)
Insert a
Document if it does not exist already and watch for durability constraints. |
<D extends Document<?>> |
insert(D document,
ReplicateTo replicateTo)
Insert a
Document if it does not exist already and watch for durability constraints. |
String |
name()
The name of the
Bucket. |
Observable<QueryPlan> |
prepare(Statement statement)
Experimental: Queries a N1QL secondary index and prepare an execution plan via the given
Statement. |
Observable<QueryPlan> |
prepare(String statement)
Experimental: Queries a N1QL secondary index and prepare an execution plan via the given statement in
String form. |
<D extends Document<?>> |
prepend(D document)
Prepend a
Document to another one. |
Observable<AsyncQueryResult> |
query(Query query)
Experimental: Queries a N1QL secondary index.
|
Observable<AsyncSpatialViewResult> |
query(SpatialViewQuery query)
Queries a Couchbase Server Spatial
View. |
Observable<AsyncQueryResult> |
query(Statement statement)
Experimental: Queries a N1QL secondary index with a simple
Statement. |
Observable<AsyncViewResult> |
query(ViewQuery query)
Queries a Couchbase Server
View. |
<D extends Document<?>> |
remove(D document)
Removes a
Document from the Server. |
<D extends Document<?>> |
remove(D document,
PersistTo persistTo)
Removes a
Document from the Server and apply a durability requirement. |
<D extends Document<?>> |
remove(D document,
PersistTo persistTo,
ReplicateTo replicateTo)
Removes a
Document from the Server and apply a durability requirement. |
<D extends Document<?>> |
remove(D document,
ReplicateTo replicateTo)
Removes a
Document from the Server and apply a durability requirement. |
Observable<JsonDocument> |
remove(String id)
Removes a
Document from the Server identified by its ID. |
<D extends Document<?>> |
remove(String id,
Class<D> target)
Removes a
Document from the Server identified by its ID. |
Observable<JsonDocument> |
remove(String id,
PersistTo persistTo)
Removes a
Document from the Server by its ID and apply a durability requirement. |
<D extends Document<?>> |
remove(String id,
PersistTo persistTo,
Class<D> target)
Removes a
Document from the Server by its ID and apply a durability requirement. |
Observable<JsonDocument> |
remove(String id,
PersistTo persistTo,
ReplicateTo replicateTo)
Removes a
Document from the Server by its ID and apply a durability requirement. |
<D extends Document<?>> |
remove(String id,
PersistTo persistTo,
ReplicateTo replicateTo,
Class<D> target)
Removes a
Document from the Server by its ID and apply a durability requirement. |
Observable<JsonDocument> |
remove(String id,
ReplicateTo replicateTo)
Removes a
Document from the Server by its ID and apply a durability requirement. |
<D extends Document<?>> |
remove(String id,
ReplicateTo replicateTo,
Class<D> target)
Removes a
Document from the Server by its ID and apply a durability requirement. |
<D extends Document<?>> |
replace(D document)
Replace a
Document if it does already exist. |
<D extends Document<?>> |
replace(D document,
PersistTo persistTo)
Replace a
Document if it does exist and watch for durability constraints. |
<D extends Document<?>> |
replace(D document,
PersistTo persistTo,
ReplicateTo replicateTo)
Replace a
Document if it does exist and watch for durability constraints. |
<D extends Document<?>> |
replace(D document,
ReplicateTo replicateTo)
Replace a
Document if it does exist and watch for durability constraints. |
String |
toString() |
<D extends Document<?>> |
touch(D document)
Renews the expiration time of a
Document. |
Observable<Boolean> |
touch(String id,
int expiry)
Renews the expiration time of a
Document. |
<D extends Document<?>> |
unlock(D document)
Unlocks a write-locked
Document. |
Observable<Boolean> |
unlock(String id,
long cas)
Unlocks a write-locked
Document. |
<D extends Document<?>> |
upsert(D document)
Insert or replace a
Document. |
<D extends Document<?>> |
upsert(D document,
PersistTo persistTo)
Insert or replace a
Document and watch for durability constraints. |
<D extends Document<?>> |
upsert(D document,
PersistTo persistTo,
ReplicateTo replicateTo)
Insert or replace a
Document and watch for durability constraints. |
<D extends Document<?>> |
upsert(D document,
ReplicateTo replicateTo)
Insert or replace a
Document and watch for durability constraints. |
public static final JsonTranscoder JSON_OBJECT_TRANSCODER
public static final JsonArrayTranscoder JSON_ARRAY_TRANSCODER
public static final JsonBooleanTranscoder JSON_BOOLEAN_TRANSCODER
public static final JsonDoubleTranscoder JSON_DOUBLE_TRANSCODER
public static final JsonLongTranscoder JSON_LONG_TRANSCODER
public static final JsonStringTranscoder JSON_STRING_TRANSCODER
public static final RawJsonTranscoder RAW_JSON_TRANSCODER
public static final LegacyTranscoder LEGACY_TRANSCODER
public static final BinaryTranscoder BINARY_TRANSCODER
public static final StringTranscoder STRING_TRANSCODER
public static final SerializableTranscoder SERIALIZABLE_TRANSCODER
public CouchbaseAsyncBucket(com.couchbase.client.core.ClusterFacade core,
CouchbaseEnvironment environment,
String name,
String password,
List<Transcoder<? extends Document,?>> customTranscoders)
public String name()
AsyncBucketThe name of the Bucket.
name in interface AsyncBucketpublic Observable<com.couchbase.client.core.ClusterFacade> core()
AsyncBucketReturns the underlying “core-io” library through its ClusterFacade.
Handle with care, with great power comes great responsibility. All additional checks which are normally performed by this library are skipped.
core in interface AsyncBucketClusterFacade from the “core-io” package.public Observable<JsonDocument> get(String id)
AsyncBucketRetrieves a JsonDocument by its unique ID.
If the document is found, a JsonDocument is returned. If the document is not found, the Observable completes without an item emitted.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.get in interface AsyncBucketid - the unique ID of the document.Observable eventually containing the found JsonDocument.public <D extends Document<?>> Observable<D> get(D document)
AsyncBucketRetrieves any type of Document by its unique ID.
The document ID is taken out of the Document provided, as well as the target type to return. Note that not the same document is returned, but rather a new one of the same type with the freshly loaded properties.
If the document is found, a Document is returned. If the document is not found, the Observable completes without an item emitted.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.get in interface AsyncBucketdocument - the source document from which the ID is taken and the type is inferred.Observable eventually containing the found Document.public <D extends Document<?>> Observable<D> get(String id, Class<D> target)
AsyncBucketRetrieves any type of Document by its unique ID.
This method differs from AsyncBucket.get(String) in that if a specific Document type is passed in, the appropriate Transcoder will be selected (and not JSON conversion).
If the document is found, a Document is returned. If the document is not found, the Observable completes without an item emitted.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.get in interface AsyncBucketid - the unique ID of the document.target - the target document type to use.Observable eventually containing the found Document.public Observable<JsonDocument> getAndLock(String id, int lockTime)
AsyncBucketRetrieve and lock a JsonDocument by its unique ID.
If the document is found, a JsonDocument is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(String), but in addition it (write) locks the document for the given lock time interval. Note that this lock time is hard capped to 30 seconds, even if provided with a higher value and is not configurable. The document will unlock afterwards automatically.
Detecting an already locked document is done by checking for TemporaryLockFailureException. Note that this exception can also be raised in other conditions, always when the error is transient and retrying may help.
The returned Observable can error under the following conditions:
TemporaryLockFailureExceptionBackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getAndLock in interface AsyncBucketid - id the unique ID of the document.lockTime - the time to write lock the document (max. 30 seconds).Observable eventually containing the found JsonDocument.public <D extends Document<?>> Observable<D> getAndLock(D document, int lockTime)
AsyncBucketRetrieve and lock a Document by its unique ID.
If the document is found, a Document is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(Document), but in addition it (write) locks the document for the given lock time interval. Note that this lock time is hard capped to 30 seconds, even if provided with a higher value and is not configurable. The document will unlock afterwards automatically.
Detecting an already locked document is done by checking for TemporaryLockFailureException. Note that this exception can also be raised in other conditions, always when the error is transient and retrying may help.
The returned Observable can error under the following conditions:
TemporaryLockFailureExceptionBackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getAndLock in interface AsyncBucketdocument - the source document from which the ID is taken and the type is inferred.lockTime - the time to write lock the document (max. 30 seconds).Observable eventually containing the found Document.public <D extends Document<?>> Observable<D> getAndLock(String id, int lockTime, Class<D> target)
AsyncBucketRetrieve and lock a Document by its unique ID.
This method differs from AsyncBucket.getAndLock(String, int) in that if a specific Document type is passed in, the appropriate Transcoder will be selected (and not JSON conversion).
If the document is found, a Document is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(String), but in addition it (write) locks the document for the given lock time interval. Note that this lock time is hard capped to 30 seconds, even if provided with a higher value and is not configurable. The document will unlock afterwards automatically.
Detecting an already locked document is done by checking for TemporaryLockFailureException. Note that this exception can also be raised in other conditions, always when the error is transient and retrying may help.
The returned Observable can error under the following conditions: - In case of transient error, most probably because key is already locked: TemporaryLockFailureException - The producer outpaces the SDK: BackpressureException - The operation had to be cancelled while on the wire or the retry strategy cancelled it instead of retrying: RequestCancelledException - The server is currently not able to process the request, retrying may help: TemporaryFailureException - The server is out of memory: CouchbaseOutOfMemoryException - Unexpected errors are caught and contained in a generic CouchbaseException.
getAndLock in interface AsyncBucketid - id the unique ID of the document.lockTime - the time to write lock the document (max. 30 seconds).target - the target document type to use.Observable eventually containing the found Document.public Observable<JsonDocument> getAndTouch(String id, int expiry)
AsyncBucketRetrieve and touch a JsonDocument by its unique ID.
If the document is found, a JsonDocument is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(String), but in addition it touches the document, which will reset its configured expiration time to the value provided.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getAndTouch in interface AsyncBucketid - id the unique ID of the document.expiry - the new expiration time for the document.Observable eventually containing the found JsonDocument.public <D extends Document<?>> Observable<D> getAndTouch(D document)
AsyncBucketRetrieve and touch a Document by its unique ID.
If the document is found, a Document is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(Document), but in addition it touches the document, which will reset its configured expiration time set on the given document itself.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getAndTouch in interface AsyncBucketdocument - the source document from which the ID and expiry is taken and the type is inferred.Observable eventually containing the found Document.public <D extends Document<?>> Observable<D> getAndTouch(String id, int expiry, Class<D> target)
AsyncBucketRetrieve and touch a Document by its unique ID.
This method differs from AsyncBucket.getAndTouch(String, int) in that if a specific Document type is passed in, the appropriate Transcoder will be selected (and not JSON conversion).
If the document is found, a JsonDocument is returned. If the document is not found, the Observable completes without an item emitted.
This method works similar to AsyncBucket.get(String, Class), but in addition it touches the document, which will reset its configured expiration time to the value provided.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getAndTouch in interface AsyncBucketid - id the unique ID of the document.expiry - the new expiration time for the document.target - the target document type to use.Observable eventually containing the found Document.public Observable<JsonDocument> getFromReplica(String id, ReplicaMode type)
AsyncBucketRetrieves one or more, possibly stale, representations of a JsonDocument by its unique ID.
Depending on the ReplicaMode selected, there can be none to four JsonDocument be returned from the Observable. If ReplicaMode.FIRST, ReplicaMode.SECOND or ReplicaMode.THIRD are selected zero or one documents are returned, if ReplicaMode.ALL is used, all configured replicas plus the master node may return a document.
If the document has not been replicated yet or if the replica or master are not available (because a node has been failed over), no response is expected from these nodes.
Since data is replicated asynchronously, all data returned from this method must be considered stale. If the appropriate ReplicateTo constraints are set on write and the operation returns successfully, then the data can be considered as non-stale.
Note that the returning JsonDocument responses can come in any order.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getFromReplica in interface AsyncBucketid - id the unique ID of the document.type - the ReplicaMode to select.Observable eventually containing zero to N JsonDocuments.public <D extends Document<?>> Observable<D> getFromReplica(D document, ReplicaMode type)
AsyncBucketRetrieves one or more, possibly stale, representations of a Document by its unique ID.
The document ID is taken out of the Document provided, as well as the target type to return. Note that not the same document is returned, but rather a new one of the same type with the freshly loaded properties.
Depending on the ReplicaMode selected, there can be none to four Document be returned from the Observable. If ReplicaMode.FIRST, ReplicaMode.SECOND or ReplicaMode.THIRD are selected zero or one documents are returned, if ReplicaMode.ALL is used, all configured replicas plus the master node may return a document.
If the document has not been replicated yet or if the replica or master are not available (because a node has been failed over), no response is expected from these nodes.
Since data is replicated asynchronously, all data returned from this method must be considered stale. If the appropriate ReplicateTo constraints are set on write and the operation returns successfully, then the data can be considered as non-stale.
Note that the returning Document responses can come in any order.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getFromReplica in interface AsyncBucketdocument - the source document from which the ID is taken and the type is inferred.type - the ReplicaMode to select.Observable eventually containing zero to N Documents.public <D extends Document<?>> Observable<D> getFromReplica(String id, ReplicaMode type, Class<D> target)
AsyncBucketRetrieves one or more, possibly stale, representations of a Document by its unique ID.
This method differs from AsyncBucket.getFromReplica(String, ReplicaMode) in that if a specific Document type is passed in, the appropriate Transcoder will be selected (and not JSON conversion).
Depending on the ReplicaMode selected, there can be none to four Document be returned from the Observable. If ReplicaMode.FIRST, ReplicaMode.SECOND or ReplicaMode.THIRD are selected zero or one documents are returned, if ReplicaMode.ALL is used, all configured replicas plus the master node may return a document.
If the document has not been replicated yet or if the replica or master are not available (because a node has been failed over), no response is expected from these nodes.
Since data is replicated asynchronously, all data returned from this method must be considered stale. If the appropriate ReplicateTo constraints are set on write and the operation returns successfully, then the data can be considered as non-stale.
Note that the returning Document responses can come in any order.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.getFromReplica in interface AsyncBucketid - id the unique ID of the document.type - the ReplicaMode to select.target - the target document type to use.Observable eventually containing zero to N Documents.public <D extends Document<?>> Observable<D> insert(D document)
AsyncBucketInsert a Document if it does not exist already.
If the given Document (identified by its unique ID) already exists, the observable errors with a DocumentAlreadyExistsException. If the operation should also override the existing Document, AsyncBucket.upsert(Document) should be used instead. It will always either return a document or fail with an error.
The returned Document contains original properties, but has the refreshed CAS value set.
This operation will return successfully if the Document has been acknowledged in the managed cache layer on the master server node. If increased data durability is a concern, AsyncBucket.insert(Document, PersistTo, ReplicateTo) should be used instead.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentAlreadyExistsExceptionRequestTooBigExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.insert in interface AsyncBucketdocument - the Document to insert.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> insert(D document, PersistTo persistTo, ReplicateTo replicateTo)
AsyncBucketInsert a Document if it does not exist already and watch for durability constraints.
This method works exactly like AsyncBucket.insert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentAlreadyExistsExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original insert has already happened, so the actual insert and the watching for durability constraints are two separate tasks internally.
insert in interface AsyncBucketdocument - the Document to insert.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> upsert(D document)
AsyncBucketInsert or replace a Document.
If the given Document (identified by its unique ID) already exists, it will be overridden by the current one. The returned Document contains original properties, but has the refreshed CAS value set.
This operation will return successfully if the Document has been acknowledged in the managed cache layer on the master server node. If increased data durability is a concern, AsyncBucket.upsert(Document, PersistTo, ReplicateTo) should be used instead.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.upsert in interface AsyncBucketdocument - the Document to upsert.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> upsert(D document, PersistTo persistTo, ReplicateTo replicateTo)
AsyncBucketInsert or replace a Document and watch for durability constraints.
This method works exactly like AsyncBucket.upsert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original upsert has already happened, so the actual upsert and the watching for durability constraints are two separate tasks internally.
upsert in interface AsyncBucketdocument - the Document to upsert.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> replace(D document)
AsyncBucketReplace a Document if it does already exist.
If the given Document (identified by its unique ID) does not exist already, the method errors with a DocumentDoesNotExistException. If the operation should also insert the Document, AsyncBucket.upsert(Document) should be used instead. It will always either return a document or fail with an error.
The returned Document contains original properties, but has the refreshed CAS value set.
This operation will return successfully if the Document has been acknowledged in the managed cache layer on the master server node. If increased data durability is a concern, AsyncBucket.replace(Document, PersistTo, ReplicateTo) should be used instead.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionRequestTooBigExceptionCASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.replace in interface AsyncBucketdocument - the Document to replace.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> replace(D document, PersistTo persistTo, ReplicateTo replicateTo)
AsyncBucketReplace a Document if it does exist and watch for durability constraints.
This method works exactly like AsyncBucket.replace(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionRequestTooBigExceptionDurabilityException.CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original replace has already happened, so the actual replace and the watching for durability constraints are two separate tasks internally.
replace in interface AsyncBucketdocument - the Document to replace.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> remove(D document)
AsyncBucketRemoves a Document from the Server.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionDocument and it did not match with the server: CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketdocument - the document to remove, with the ID extracted.public Observable<JsonDocument> remove(String id)
AsyncBucketRemoves a Document from the Server identified by its ID.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.public <D extends Document<?>> Observable<D> remove(String id, Class<D> target)
AsyncBucketRemoves a Document from the Server identified by its ID.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.target - the target document type to use.public <D extends Document<?>> Observable<D> remove(D document, PersistTo persistTo, ReplicateTo replicateTo)
AsyncBucketRemoves a Document from the Server and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionDocument and it did not match with the server: CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketdocument - the document to remove, with the ID extracted.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.public Observable<JsonDocument> remove(String id, PersistTo persistTo, ReplicateTo replicateTo)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.public <D extends Document<?>> Observable<D> remove(String id, PersistTo persistTo, ReplicateTo replicateTo, Class<D> target)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.persistTo - the persistence constraint to watch.replicateTo - the replication constraint to watch.target - the target document type to use.public Observable<AsyncViewResult> query(ViewQuery query)
AsyncBucketQueries a Couchbase Server View.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionViewDoesNotExistExceptionquery in interface AsyncBucketquery - the query to perform.public Observable<AsyncSpatialViewResult> query(SpatialViewQuery query)
AsyncBucketQueries a Couchbase Server Spatial View.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionViewDoesNotExistExceptionquery in interface AsyncBucketquery - the spatial query to perform.public Observable<AsyncQueryResult> query(Statement statement)
AsyncBucketExperimental: Queries a N1QL secondary index with a simple Statement.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionquery in interface AsyncBucketstatement - the statement in a DSL form (start with a static select() import).public Observable<AsyncQueryResult> query(Query query)
AsyncBucketExperimental: Queries a N1QL secondary index.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionquery in interface AsyncBucketquery - the full Query.public Observable<QueryPlan> prepare(String statement)
AsyncBucketExperimental: Queries a N1QL secondary index and prepare an execution plan via the given statement in String form. Statement can contain placeholders. The resulting QueryPlan can be cached and (re)used later in a PreparedQuery.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionprepare in interface AsyncBucketstatement - the statement to prepare a plan for.QueryPlan that can be cached and reused later in PreparedQuery.public Observable<QueryPlan> prepare(Statement statement)
AsyncBucketExperimental: Queries a N1QL secondary index and prepare an execution plan via the given Statement. Statement can contain placeholders. The resulting QueryPlan can be cached and (re)used later in a PreparedQuery.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionprepare in interface AsyncBucketstatement - the statement to prepare a plan for.QueryPlan that can be cached and reused later in PreparedQuery.public Observable<JsonLongDocument> counter(String id, long delta)
AsyncBucketIncrement or decrement a counter with the given value and a default value of 0.
It is not allowed that the delta value will bring the actual value below zero.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.counter in interface AsyncBucketid - the id of the document.delta - the increment or decrement amount.Document containing the resulting value.public Observable<JsonLongDocument> counter(String id, long delta, long initial)
AsyncBucketIncrement or decrement a counter with the given value and a initial value if it does not exist.
It is not allowed that the delta value will bring the actual value below zero.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.counter in interface AsyncBucketid - the id of the document.delta - the increment or decrement amount.Document containing the resulting value.public Observable<JsonLongDocument> counter(String id, long delta, long initial, int expiry)
AsyncBucketIncrement or decrement a counter with the given value and a initial value if it does not exist.
This method allows to set an expiration time for the document as well. It is not allowed that the delta value will bring the actual value below zero.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.counter in interface AsyncBucketid - the id of the document.delta - the increment or decrement amount.Document containing the resulting value.public Observable<Boolean> unlock(String id, long cas)
AsyncBucketUnlocks a write-locked Document.
The returned Observable can error under the following conditions:
TemporaryLockFailureExceptionBackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.unlock in interface AsyncBucketid - the id of the document to unlock.cas - the CAS value which is mandatory to unlock it.public <D extends Document<?>> Observable<Boolean> unlock(D document)
AsyncBucketUnlocks a write-locked Document.
The returned Observable can error under the following conditions:
DocumentDoesNotExistExceptionTemporaryLockFailureExceptionBackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.unlock in interface AsyncBucketdocument - the document where ID and CAS are extracted from.public Observable<Boolean> touch(String id, int expiry)
AsyncBucketRenews the expiration time of a Document.
Compared to AsyncBucket.getAndTouch(Document), this method does not actually fetch the document from the server, but it just resets its expiration time to the given value.
The returned Observable can error under the following conditions:
DocumentDoesNotExistExceptionBackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.touch in interface AsyncBucketid - the id of the document.expiry - the new expiration time. 0 means no expiry.public <D extends Document<?>> Observable<Boolean> touch(D document)
AsyncBucketRenews the expiration time of a Document.
Compared to AsyncBucket.getAndTouch(Document), this method does not actually fetch the document from the server, but it just resets its expiration time to the given value.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.touch in interface AsyncBucketdocument - the document to extract the ID and expiry from.public <D extends Document<?>> Observable<D> append(D document)
AsyncBucketAppend a Document to another one.
The Document returned explicitly has the Document.content() set to null, because the server does not return the appended result, so at this point the client does not know how the Document now looks like. A separate AsyncBucket.get(Document) call needs to be issued in order to get the full current content.
If the Document does not exist, it needs to be created upfront. Note that JsonDocuments in all forms are not supported, it is advised that the following ones are used:
Note that this method does not support expiration on the Document. If set, it will be ignored.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.append in interface AsyncBucketdocument - the document to be appended.public <D extends Document<?>> Observable<D> prepend(D document)
AsyncBucketPrepend a Document to another one.
The Document returned explicitly has the Document.content() set to null, because the server does not return the prepended result, so at this point the client does not know how the Document now looks like. A separate AsyncBucket.get(Document) call needs to be issued in order to get the full current content.
If the Document does not exist, it needs to be created upfront. Note that JsonDocuments in all forms are not supported, it is advised that the following ones are used:
Note that this method does not support expiration on the Document. If set, it will be ignored.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionDocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.prepend in interface AsyncBucketdocument - the document to be prepended.public Observable<AsyncBucketManager> bucketManager()
AsyncBucketProvides access to the AsyncBucketManager for administrative access.
The manager lets you perform operations such as flushing a bucket or creating and managing design documents.
bucketManager in interface AsyncBucketpublic <D extends Document<?>> Observable<D> insert(D document, PersistTo persistTo)
AsyncBucketInsert a Document if it does not exist already and watch for durability constraints.
This method works exactly like AsyncBucket.insert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentAlreadyExistsExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original insert has already happened, so the actual insert and the watching for durability constraints are two separate tasks internally.
insert in interface AsyncBucketdocument - the Document to insert.persistTo - the persistence constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> insert(D document, ReplicateTo replicateTo)
AsyncBucketInsert a Document if it does not exist already and watch for durability constraints.
This method works exactly like AsyncBucket.insert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentAlreadyExistsExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original insert has already happened, so the actual insert and the watching for durability constraints are two separate tasks internally.
insert in interface AsyncBucketdocument - the Document to insert.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> upsert(D document, PersistTo persistTo)
AsyncBucketInsert or replace a Document and watch for durability constraints.
This method works exactly like AsyncBucket.upsert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original upsert has already happened, so the actual upsert and the watching for durability constraints are two separate tasks internally.
upsert in interface AsyncBucketdocument - the Document to upsert.persistTo - the persistence constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> upsert(D document, ReplicateTo replicateTo)
AsyncBucketInsert or replace a Document and watch for durability constraints.
This method works exactly like AsyncBucket.upsert(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionRequestTooBigExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original upsert has already happened, so the actual upsert and the watching for durability constraints are two separate tasks internally.
upsert in interface AsyncBucketdocument - the Document to upsert.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> replace(D document, PersistTo persistTo)
AsyncBucketReplace a Document if it does exist and watch for durability constraints.
This method works exactly like AsyncBucket.replace(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionRequestTooBigExceptionDurabilityException.CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original replace has already happened, so the actual replace and the watching for durability constraints are two separate tasks internally.
replace in interface AsyncBucketdocument - the Document to replace.persistTo - the persistence constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> replace(D document, ReplicateTo replicateTo)
AsyncBucketReplace a Document if it does exist and watch for durability constraints.
This method works exactly like AsyncBucket.replace(Document), but afterwards watches the server states if the given durability constraints are met. If this is the case, a new document is returned which contains the original properties, but has the refreshed CAS value set.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionRequestTooBigExceptionDurabilityException.CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.A DurabilityException typically happens if the given amount of replicas needed to fulfill the durability constraint cannot be met because either the bucket does not have enough replicas configured or they are not available in a failover event. As an example, if one replica is configured and ReplicateTo.TWO is used, the observable is errored with a DurabilityException. The same can happen if one replica is configured, but one node has been failed over and not yet rebalanced (hence, on a subset of the partitions there is no replica available). It is important to understand that the original replace has already happened, so the actual replace and the watching for durability constraints are two separate tasks internally.
replace in interface AsyncBucketdocument - the Document to replace.replicateTo - the replication constraint to watch.Observable eventually containing a new Document.public <D extends Document<?>> Observable<D> remove(D document, PersistTo persistTo)
AsyncBucketRemoves a Document from the Server and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionDocument and it did not match with the server: CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketdocument - the document to remove, with the ID extracted.persistTo - the persistence constraint to watch.public <D extends Document<?>> Observable<D> remove(D document, ReplicateTo replicateTo)
AsyncBucketRemoves a Document from the Server and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionDocument and it did not match with the server: CASMismatchExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketdocument - the document to remove, with the ID extracted.replicateTo - the replication constraint to watch.public Observable<JsonDocument> remove(String id, PersistTo persistTo)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.persistTo - the persistence constraint to watch.public Observable<JsonDocument> remove(String id, ReplicateTo replicateTo)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDocumentDoesNotExistExceptionDurabilityException.TemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.replicateTo - the replication constraint to watch.public <D extends Document<?>> Observable<D> remove(String id, PersistTo persistTo, Class<D> target)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.persistTo - the persistence constraint to watch.target - the target document type to use.public <D extends Document<?>> Observable<D> remove(String id, ReplicateTo replicateTo, Class<D> target)
AsyncBucketRemoves a Document from the Server by its ID and apply a durability requirement.
The Document returned just has the document ID and its CAS value set, since the value and all other associated properties have been removed from the server.
The returned Observable can error under the following conditions:
BackpressureExceptionRequestCancelledExceptionDurabilityException.DocumentDoesNotExistExceptionTemporaryFailureExceptionCouchbaseOutOfMemoryExceptionCouchbaseException.remove in interface AsyncBucketid - the id of the document to remove.replicateTo - the replication constraint to watch.target - the target document type to use.public Observable<Boolean> close()
AsyncBucketCloses the AsyncBucket.
close in interface AsyncBucketObservable eventually containing a new Boolean after close.Copyright © 2014 Couchbase, Inc.