Module: Couchbase::Operations::Fetch

Defined in:
lib/couchbase/operations/fetch.rb

Instance Method Summary collapse

Instance Method Details

#fetch(key, set_options = {}, get_options = {}, &block) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/couchbase/operations/fetch.rb', line 23

def fetch(key, set_options = {}, get_options = {}, &block)
  fail ArgumentError 'Must pass a block to #fetch' unless block_given?

  get_options[:quiet] = false
  get(key, get_options)
rescue Couchbase::Error::NotFound
  yield(block).tap {|value| set(key, value, set_options) }
end