use of com.couchbase.client.java.kv.GetAndTouchOptions in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method getAndTouch.
/**
* Fetches a full document and resets its expiration time to the value provided with custom
* options.
*
* @param id the document id which is used to uniquely identify it.
* @param expiry the new expiration time for the document.
* @param options custom options to change the default behavior.
* @return a {@link CompletableFuture} completing once loaded or failed.
*/
public CompletableFuture<GetResult> getAndTouch(final String id, final Duration expiry, final GetAndTouchOptions options) {
notNull(expiry, "Expiry", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(options, "GetAndTouchOptions", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
GetAndTouchOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment.transcoder() : opts.transcoder();
return GetAccessor.getAndTouch(core, getAndTouchRequest(id, Expiry.relative(expiry), opts), transcoder);
}
use of com.couchbase.client.java.kv.GetAndTouchOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method getAndTouch.
/**
* Fetches a full document and resets its expiration time to the value provided with custom
* options.
*
* @param id the document id which is used to uniquely identify it.
* @param expiry the new expiration time for the document.
* @param options custom options to change the default behavior.
* @return a {@link Mono} completing once loaded or failed.
*/
public Mono<GetResult> getAndTouch(final String id, final Duration expiry, final GetAndTouchOptions options) {
return Mono.defer(() -> {
GetAndTouchOptions.Built opts = options.build();
final Transcoder transcoder = opts.transcoder() == null ? environment().transcoder() : opts.transcoder();
GetAndTouchRequest request = asyncCollection.getAndTouchRequest(id, Expiry.relative(expiry), opts);
return Reactor.wrap(request, GetAccessor.getAndTouch(core, request, transcoder), true);
});
}
Aggregations