Class: Couchbase::Options::MutateIn

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/options.rb

Overview

Options for Collection#mutate_in

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(expiry: nil, preserve_expiry: false, store_semantics: :replace, cas: nil, access_deleted: false, create_as_deleted: false, durability_level: :none, replicate_to: :none, persist_to: :none, transcoder: JsonTranscoder.new, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|| ... } ⇒ MutateIn

Creates an instance of options for Collection#mutate_in

Parameters:

  • expiry (Integer, #in_seconds, Time, nil) (defaults to: nil) —

    expiration time to associate with the document

  • preserve_expiry (Boolean) (defaults to: false) —

    if true and the document exists, the server will preserve current expiration for the document, otherwise will use #expiry from the operation.

  • store_semantics (Symbol) (defaults to: :replace) —

    describes how the outer document store semantics on subdoc should act :replace:: replace the document, fail if it does not exist. This is the default :upsert:: replace the document or create if it does not exist :insert:: create the document, fail if it exists

  • cas (Integer, nil) (defaults to: nil) —

    a CAS value that will be taken into account on the server side for optimistic concurrency

  • access_deleted (Boolean) (defaults to: false) —

    for internal use only: allows access to deleted documents that are in "tombstone" form

  • create_as_deleted (Boolean) (defaults to: false) —

    for internal use only: allows creating documents in "tombstone" form

  • durability_level (Symbol) (defaults to: :none) —

    level of durability :none::

    no enhanced durability required for the mutation
    

    :majority::

    the mutation must be replicated to a majority of the Data Service nodes
    (that is, held in the memory allocated to the bucket)
    

    :majority_and_persist_to_active::

    The mutation must be replicated to a majority of the Data Service nodes.
    Additionally, it must be persisted (that is, written and synchronised to disk) on the
    node hosting the active partition (vBucket) for the data.
    

    :persist_to_majority::

    The mutation must be persisted to a majority of the Data Service nodes.
    Accordingly, it will be written to disk on those nodes.
  • replicate_to (Symbol) (defaults to: :none) —

    number of nodes to replicate :none:: do not apply any replication requirements. :one:: wait for replication to at least one node. :two:: wait for replication to at least two nodes. :three:: wait for replication to at least three nodes.

  • persist_to (Symbol) (defaults to: :none) —

    number of nodes to persist :none:: do not apply any persistence requirements. :active:: wait for persistence to active node :one:: wait for persistence to at least one node. :two:: wait for persistence to at least two nodes. :three:: wait for persistence to at least three nodes. :four:: wait for persistence to four nodes (active and replicas).

  • transcoder (JsonTranscoder, #encode(Object)) (defaults to: JsonTranscoder.new) —

    used for encoding

  • timeout (Integer, #in_milliseconds, nil) (defaults to: nil)
  • retry_strategy (Symbol, nil) (defaults to: nil) —

    :best_effort or :fail_fast; the cluster's default when nil

  • client_context (Hash, nil) (defaults to: nil) —

    the client context data, if set

  • parent_span (Span, nil) (defaults to: nil) —

    if set holds the parent span, that should be used for this request

Yield Parameters:



997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'lib/couchbase/options.rb', line 997

def initialize(expiry: nil,
               preserve_expiry: false,
               store_semantics: :replace,
               cas: nil,
               access_deleted: false,
               create_as_deleted: false,
               durability_level: :none,
               replicate_to: :none,
               persist_to: :none,
               transcoder: JsonTranscoder.new,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
  @expiry = expiry
  @preserve_expiry = preserve_expiry
  @store_semantics = store_semantics
  @cas = cas
  @access_deleted = access_deleted
  @create_as_deleted = create_as_deleted
  if durability_level != :none && (replicate_to != :none || persist_to != :none)
    raise ArgumentError, "durability_level conflicts with replicate_to and persist_to options"
  end

  @persist_to = persist_to
  @replicate_to = replicate_to
  @durability_level = durability_level
  @transcoder = transcoder
  yield self if block_given?
end

Instance Attribute Details

#cas ⇒ Integer?

Returns:

  • (Integer, nil)


947
948
949
# File 'lib/couchbase/options.rb', line 947

def cas
  @cas
end

#durability_level ⇒ Symbol

Returns:

  • (Symbol)


948
949
950
# File 'lib/couchbase/options.rb', line 948

def durability_level
  @durability_level
end

#expiry ⇒ Integer, ...

Returns:

  • (Integer, #in_seconds, nil)


945
946
947
# File 'lib/couchbase/options.rb', line 945

def expiry
  @expiry
end

#preserve_expiry ⇒ Boolean

Returns:

  • (Boolean)


950
951
952
# File 'lib/couchbase/options.rb', line 950

def preserve_expiry
  @preserve_expiry
end

#store_semantics ⇒ Symbol

Returns:

  • (Symbol)


946
947
948
# File 'lib/couchbase/options.rb', line 946

def store_semantics
  @store_semantics
end

#transcoder ⇒ JsonTranscoder, #encode(Object)

Returns:



949
950
951
# File 'lib/couchbase/options.rb', line 949

def transcoder
  @transcoder
end