Class: Dalli::PipelinedSetter

Inherits:
Object
  • Object
show all
Defined in:
lib/dalli/pipelined_setter.rb

Overview

Contains logic for the pipelined set operations implemented by the client. Efficiently writes multiple key-value pairs by grouping requests by server and using quiet mode to minimize round trips.

Instance Method Summary collapse

Constructor Details

#initialize(ring, key_manager) ⇒ PipelinedSetter

Returns a new instance of PipelinedSetter.



10
11
12
13
# File 'lib/dalli/pipelined_setter.rb', line 10

def initialize(ring, key_manager)
  @ring = ring
  @key_manager = key_manager
end

Instance Method Details

#process(hash, ttl, req_options) ⇒ void

This method returns an undefined value.

Writes multiple key-value pairs to memcached. Raises an error if any server is unavailable.

Parameters:

  • hash (Hash)

    key-value pairs to set

  • ttl (Integer)

    time-to-live in seconds

  • req_options (Hash)

    options passed to each set operation



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dalli/pipelined_setter.rb', line 24

def process(hash, ttl, req_options)
  return if hash.empty?

  @ring.lock do
    servers = setup_requests(hash, ttl, req_options)
    finish_requests(servers)
  end
rescue Dalli::RetryableNetworkError => e
  Dalli.logger.debug { e.inspect }
  Dalli.logger.debug { 'retrying pipelined sets because of network error' }
  retry
end