Class: Couchbase::Options::UpsertMulti

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb

Overview

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, transcoder: JsonTranscoder.new, durability_level: :none, replicate_to: :none, persist_to: :none, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|| ... } ⇒ UpsertMulti

Creates an instance of options for Collection#upsert

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.

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

    used for encoding

  • 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).

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

    the custom retry strategy, if set

  • 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:



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'lib/couchbase/options.rb', line 747

def initialize(expiry: nil,
               preserve_expiry: false,
               transcoder: JsonTranscoder.new,
               durability_level: :none,
               replicate_to: :none,
               persist_to: :none,
               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
  @transcoder = transcoder
  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
  yield self if block_given?
end

Instance Attribute Details

#durability_levelSymbol

Returns:

  • (Symbol)


706
707
708
# File 'lib/couchbase/options.rb', line 706

def durability_level
  @durability_level
end

#expiryInteger, ...

Returns:

  • (Integer, #in_seconds, nil)


704
705
706
# File 'lib/couchbase/options.rb', line 704

def expiry
  @expiry
end

#preserve_expiryBoolean

Returns:

  • (Boolean)


707
708
709
# File 'lib/couchbase/options.rb', line 707

def preserve_expiry
  @preserve_expiry
end

#transcoderJsonTranscoder, #encode(Object)

Returns:



705
706
707
# File 'lib/couchbase/options.rb', line 705

def transcoder
  @transcoder
end

Instance Method Details

#to_backendObject



771
772
773
774
775
776
777
778
779
780
# File 'lib/couchbase/options.rb', line 771

def to_backend
  {
    timeout: Utils::Time.extract_duration(@timeout),
    expiry: Utils::Time.extract_expiry_time(@expiry),
    preserve_expiry: @preserve_expiry,
    durability_level: @durability_level,
    persist_to: @persist_to,
    replicate_to: @replicate_to,
  }
end