Class: Cachext::Client

Inherits:
Object
  • Object
show all
Includes:
Features::Backup, Features::CircuitBreaker, Features::DebugLogging, Features::Default, Features::Lock
Defined in:
lib/cachext/client.rb

Constant Summary

Constants included from Features::Lock

Features::Lock::TimeoutWaitingForLock

Instance Attribute Summary

Attributes included from Features::CircuitBreaker

#breaker

Instance Method Summary collapse

Methods included from Features::Lock

#obtain_lock, #wait_for_lock, #with_heartbeat_extender

Constructor Details

#initialize(config) ⇒ Client



11
12
13
# File 'lib/cachext/client.rb', line 11

def initialize config
  @config = config
end

Instance Method Details

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



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cachext/client.rb', line 15

def fetch key, options_hash = {}, &block
  options = Options.new @config, options_hash

  retval = read key, options
  return retval unless retval.nil?

  call_block key, options, &block

rescue *Array(options.not_found_error) => e
  handle_not_found key, options, e
rescue Features::Lock::TimeoutWaitingForLock, *options.errors => e
  handle_error key, options, e
end