use of com.couchbase.client.java.kv.GetAndLockOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method getAndLock.
/**
* Fetches a full document and write-locks it for the given duration with custom options.
* <p>
* Note that the client does not enforce an upper limit on the {@link Duration} lockTime. The maximum lock time
* by default on the server is 30 seconds. Any value larger than 30 seconds will be capped down by the server to
* the default lock time, which is 15 seconds unless modified on the server side.
*
* @param id the document id which is used to uniquely identify it.
* @param lockTime how long to write-lock the document for (any duration > 30s will be capped to server default of 15s).
* @param options custom options to change the default behavior.
* @return a {@link Mono} completing once loaded or failed.
*/
public Mono<GetResult> getAndLock(final String id, final Duration lockTime, final GetAndLockOptions options) {
return Mono.defer(() -> {
GetAndLockOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment().transcoder() : opts.transcoder();
GetAndLockRequest request = asyncCollection.getAndLockRequest(id, lockTime, opts);
return Reactor.wrap(request, GetAccessor.getAndLock(core, request, transcoder), true);
});
}
use of com.couchbase.client.java.kv.GetAndLockOptions in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method getAndLock.
/**
* Fetches a full document and write-locks it for the given duration with custom options.
* <p>
* Note that the client does not enforce an upper limit on the {@link Duration} lockTime. The maximum lock time
* by default on the server is 30 seconds. Any value larger than 30 seconds will be capped down by the server to
* the default lock time, which is 15 seconds unless modified on the server side.
*
* @param id the document id which is used to uniquely identify it.
* @param lockTime how long to write-lock the document for (any duration > 30s will be capped to server default of 15s).
* @param options custom options to change the default behavior.
* @return a {@link CompletableFuture} completing once loaded or failed.
*/
public CompletableFuture<GetResult> getAndLock(final String id, final Duration lockTime, final GetAndLockOptions options) {
notNull(options, "GetAndLockOptions", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
GetAndLockOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment.transcoder() : opts.transcoder();
return GetAccessor.getAndLock(core, getAndLockRequest(id, lockTime, opts), transcoder);
}
Aggregations