chanzuckerberg / redis-memo

A Redis-based version addressable caching system. Memoize pure functions, aggregated database queries, and 3rd party API calls.
https://rubygems.org/gems/redis-memo
MIT License
33 stars 3 forks source link

[bug fix] Rescue ConnectionPool::TimeoutError #64

Closed katyho closed 3 years ago

katyho commented 3 years ago

Summary

redis_cache_store only rescues Redis::BaseErrors. We should also rescue ConnectionPool::TimeoutErrors thrown from the connection_pool gem, since these are transient and shouldn't fail the request if the cache read/write fails.

Overwrite the private method failsafe defined in redis_cache_store to also catch ConnectionPool::TimeoutErrors.

Test Plan

codecov[bot] commented 3 years ago

Codecov Report

Merging #64 (d3846d3) into main (b1b590d) will increase coverage by 0.02%. The diff coverage is 96.00%.

:exclamation: Current head d3846d3 differs from pull request most recent head 72c1086. Consider uploading reports for the commit 72c1086 to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   97.34%   97.36%   +0.02%     
==========================================
  Files          34       34              
  Lines        2186     2204      +18     
==========================================
+ Hits         2128     2146      +18     
  Misses         58       58              
Impacted Files Coverage Δ
spec/cache_spec.rb 98.90% <95.00%> (+0.18%) :arrow_up:
lib/redis_memo/cache.rb 98.38% <100.00%> (+0.14%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b1b590d...72c1086. Read the comment docs.