Skip to content

Commit

Permalink
Merge 7eab7f7 into 2bdf793
Browse files Browse the repository at this point in the history
  • Loading branch information
spk committed Mar 13, 2018
2 parents 2bdf793 + 7eab7f7 commit d698c0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/readthis/cache.rb
Expand Up @@ -472,7 +472,7 @@ def invoke(operation, key, &block)
instrument(operation, key) do
pool.with(&block)
end
rescue Redis::BaseError => error
rescue Redis::BaseError, Errno::EADDRNOTAVAIL => error
raise error unless Readthis.fault_tolerant?
end

Expand Down
10 changes: 10 additions & 0 deletions spec/readthis/cache_spec.rb
Expand Up @@ -225,6 +225,16 @@ def self.load(value)

expect(computed).to eq('computed')
end

it 'serves computed content when the cache is not available and tolerance is enabled' do
Readthis.fault_tolerant = true

allow(cache.pool).to receive(:with).and_raise(Errno::EADDRNOTAVAIL)

computed = cache.fetch('error-key') { 'computed' }

expect(computed).to eq('computed')
end
end

describe '#read_multi' do
Expand Down

0 comments on commit d698c0c

Please sign in to comment.