aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorfatkodima <fatkodima@rambler.ru>2017-12-16 22:33:22 +0200
committerfatkodima <fatkodima123@gmail.com>2018-01-23 00:34:21 +0200
commitbd54991d20aa30a76815ce80912c8122a2e4ffd3 (patch)
tree3920d4c9e0e6986911fd6433ddc1006132258757 /activesupport/lib
parent05b7b80bcaeeb0357cdb6143fbeca1b3c73b5fb9 (diff)
downloadrails-bd54991d20aa30a76815ce80912c8122a2e4ffd3.tar.gz
rails-bd54991d20aa30a76815ce80912c8122a2e4ffd3.tar.bz2
rails-bd54991d20aa30a76815ce80912c8122a2e4ffd3.zip
Improve fault tolerance for redis cache store
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache/redis_cache_store.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb
index 3347576651..c4cd9c4761 100644
--- a/activesupport/lib/active_support/cache/redis_cache_store.rb
+++ b/activesupport/lib/active_support/cache/redis_cache_store.rb
@@ -253,7 +253,9 @@ module ActiveSupport
# Failsafe: Raises errors.
def increment(name, amount = 1, options = nil)
instrument :increment, name, amount: amount do
- redis.with { |c| c.incrby normalize_key(name, options), amount }
+ failsafe :increment do
+ redis.with { |c| c.incrby normalize_key(name, options), amount }
+ end
end
end
@@ -267,7 +269,9 @@ module ActiveSupport
# Failsafe: Raises errors.
def decrement(name, amount = 1, options = nil)
instrument :decrement, name, amount: amount do
- redis.with { |c| c.decrby normalize_key(name, options), amount }
+ failsafe :decrement do
+ redis.with { |c| c.decrby normalize_key(name, options), amount }
+ end
end
end
@@ -343,7 +347,10 @@ module ActiveSupport
options = merged_options(options)
keys = names.map { |name| normalize_key(name, options) }
- values = redis.with { |c| c.mget(*keys) }
+
+ values = failsafe(:read_multi_mget, returning: {}) do
+ redis.with { |c| c.mget(*keys) }
+ end
names.zip(values).each_with_object({}) do |(name, value), results|
if value
@@ -368,7 +375,7 @@ module ActiveSupport
expires_in += 5.minutes
end
- failsafe :write_entry do
+ failsafe :write_entry, returning: false do
if unless_exist || expires_in
modifiers = {}
modifiers[:nx] = unless_exist