Package com.couchbase.client.core.msg.kv
Class InsertRequest
java.lang.Object
com.couchbase.client.core.msg.BaseRequest<R>
com.couchbase.client.core.msg.kv.BaseKeyValueRequest<InsertResponse>
com.couchbase.client.core.msg.kv.InsertRequest
- All Implemented Interfaces:
KeyValueRequest<InsertResponse>
,SyncDurabilityRequest
,Request<InsertResponse>
,ScopedRequest
public class InsertRequest
extends BaseKeyValueRequest<InsertResponse>
implements SyncDurabilityRequest
Uses the KV "add" command to insert documents if they do not already exist.
- Since:
- 2.0.0
-
Constructor Summary
ConstructorDescriptionInsertRequest
(String key, byte[] content, long expiration, int flags, Duration timeout, CoreContext ctx, CollectionIdentifier collectionIdentifier, RetryStrategy retryStrategy, Optional<DurabilityLevel> syncReplicationType, RequestSpan span) -
Method Summary
Modifier and TypeMethodDescriptiondecode
(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf response, KeyValueChannelContext ctx) Decode the encoded response into its message representation.Returns the durability level if present.com.couchbase.client.core.deps.io.netty.buffer.ByteBuf
encode
(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) Encode this request with the given allocator and opaque.name()
The unique name of the request, usually related to the type but not necessarily.Methods inherited from class com.couchbase.client.core.msg.kv.BaseKeyValueRequest
bucket, collectionIdentifier, encodedExternalKeyWithCollection, encodedKeyWithCollection, errorCode, indicateRejectedWithNotMyVbucket, key, nextOpaque, opaque, operationId, partition, partition, rejectedWithNotMyVbucket, serviceContext, serviceType
Methods inherited from class com.couchbase.client.core.msg.BaseRequest
absoluteTimeout, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, requestSpan, response, retryStrategy, succeed, succeeded, timeout, timeoutElapsed, timeoutRegistration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.couchbase.client.core.msg.Request
absoluteTimeout, cancel, cancel, cancellationReason, cancelled, completed, context, createdAt, fail, failed, id, idempotent, requestSpan, response, retryStrategy, succeed, succeeded, target, timeout, timeoutElapsed, timeoutRegistration
Methods inherited from interface com.couchbase.client.core.msg.kv.SyncDurabilityRequest
applyLevelOnSpan
-
Constructor Details
-
InsertRequest
public InsertRequest(String key, byte[] content, long expiration, int flags, Duration timeout, CoreContext ctx, CollectionIdentifier collectionIdentifier, RetryStrategy retryStrategy, Optional<DurabilityLevel> syncReplicationType, RequestSpan span)
-
-
Method Details
-
encode
public com.couchbase.client.core.deps.io.netty.buffer.ByteBuf encode(com.couchbase.client.core.deps.io.netty.buffer.ByteBufAllocator alloc, int opaque, KeyValueChannelContext ctx) Description copied from interface:KeyValueRequest
Encode this request with the given allocator and opaque.- Specified by:
encode
in interfaceKeyValueRequest<InsertResponse>
- Parameters:
alloc
- the allocator where to grab the buffers from.opaque
- the opaque value to use.ctx
- more encode context.- Returns:
- the encoded request as a
ByteBuf
.
-
decode
public InsertResponse decode(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf response, KeyValueChannelContext ctx) Description copied from interface:KeyValueRequest
Decode the encoded response into its message representation.- Specified by:
decode
in interfaceKeyValueRequest<InsertResponse>
- Parameters:
response
- the response to decode.- Returns:
- the decoded response as the generic type R.
-
durabilityLevel
Description copied from interface:SyncDurabilityRequest
Returns the durability level if present.- Specified by:
durabilityLevel
in interfaceSyncDurabilityRequest
-
name
Description copied from interface:Request
The unique name of the request, usually related to the type but not necessarily.The default implementation is derived from the class name (i.e. FooRequest returns foo), but if that does not match up it should be overridden in the actual class.
- Specified by:
name
in interfaceRequest<InsertResponse>
- Returns:
- the name of the request type.
-