use of com.couchbase.client.core.msg.kv.GetAndTouchRequest in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method getAndTouchRequest.
/**
* Helper method for get and touch requests.
*
* @param id the document id which is used to uniquely identify it.
* @param expiry the new expiration time for the document.
* @param opts custom options to change the default behavior.
* @return the get and touch request.
*/
@Stability.Internal
GetAndTouchRequest getAndTouchRequest(final String id, final Expiry expiry, final GetAndTouchOptions.Built opts) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(expiry, "Expiry", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
Duration timeout = opts.timeout().orElse(environment.timeoutConfig().kvTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_GET_AND_TOUCH, opts.parentSpan().orElse(null));
long encodedExpiry = expiry.encode();
GetAndTouchRequest request = new GetAndTouchRequest(id, timeout, coreContext, collectionIdentifier, retryStrategy, encodedExpiry, span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.core.msg.kv.GetAndTouchRequest 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