module Cachext::Features::CircuitBreaker

Attributes

breaker[R]

Public Class Methods

new(config) click to toggle source
Calls superclass method
# File lib/cachext/features/circuit_breaker.rb, line 6
def initialize config
  super
  @breaker = Breaker.new(config)
end

Public Instance Methods

handle_error(key, options, error) click to toggle source
Calls superclass method
# File lib/cachext/features/circuit_breaker.rb, line 23
def handle_error key, options, error
  breaker.for(key).increment_failure
  super
end
read(key, options) click to toggle source
Calls superclass method
# File lib/cachext/features/circuit_breaker.rb, line 11
def read key, options
  circuit = breaker.for(key)
  if circuit.open?
    val = key.read_backup
    debug_log { { m: :circuit_open, key: key, msg: "Circuit breaker open, reading from backup", val: val.inspect } }
    val
  else
    circuit.check_health
    super
  end
end