Class: Couchbase::Options::Replace

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

Overview

Options for Collection#replace

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, cas: nil, durability_level: :none, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|| ... } ⇒ Replace

Creates an instance of options for Collection#replace

Parameters:

  • expiry (Integer, #in_seconds, 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

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

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

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

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



658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'lib/couchbase/options.rb', line 658

def initialize(expiry: nil,
               preserve_expiry: false,
               transcoder: JsonTranscoder.new,
               cas: nil,
               durability_level: :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 = Utils::Time.extract_expiry_time(expiry)
  @preserve_expiry = preserve_expiry
  @transcoder = transcoder
  @cas = cas
  @durability_level = durability_level
  yield self if block_given?
end

Instance Attribute Details

#casInteger?

Returns:

  • (Integer, nil)


627
628
629
# File 'lib/couchbase/options.rb', line 627

def cas
  @cas
end

#durability_levelSymbol

Returns:

  • (Symbol)


628
629
630
# File 'lib/couchbase/options.rb', line 628

def durability_level
  @durability_level
end

#expiryInteger, ...

Returns:

  • (Integer, #in_seconds, nil)


625
626
627
# File 'lib/couchbase/options.rb', line 625

def expiry
  @expiry
end

#preserve_expiryBoolean

Returns:

  • (Boolean)


629
630
631
# File 'lib/couchbase/options.rb', line 629

def preserve_expiry
  @preserve_expiry
end

#transcoderJsonTranscoder, #encode(Object)

Returns:



626
627
628
# File 'lib/couchbase/options.rb', line 626

def transcoder
  @transcoder
end

Instance Method Details

#to_backendObject



676
677
678
679
680
681
682
683
684
# File 'lib/couchbase/options.rb', line 676

def to_backend
  {
    timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
    expiry: @expiry,
    preserve_expiry: @preserve_expiry,
    durability_level: @durability_level,
    cas: @cas,
  }
end