Search in sources :

Example 1 with GetAndTouchOptions

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);
}
Also used : GetAndTouchOptions(com.couchbase.client.java.kv.GetAndTouchOptions) Transcoder(com.couchbase.client.java.codec.Transcoder)

Example 2 with GetAndTouchOptions

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);
    });
}
Also used : GetAndTouchRequest(com.couchbase.client.core.msg.kv.GetAndTouchRequest) GetAndTouchOptions(com.couchbase.client.java.kv.GetAndTouchOptions) Transcoder(com.couchbase.client.java.codec.Transcoder)

Aggregations

Transcoder (com.couchbase.client.java.codec.Transcoder)2 GetAndTouchOptions (com.couchbase.client.java.kv.GetAndTouchOptions)2 GetAndTouchRequest (com.couchbase.client.core.msg.kv.GetAndTouchRequest)1