redis-activesupport 5.0.3 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -13
- data/lib/active_support/cache/redis_store.rb +30 -13
- data/lib/redis/active_support/version.rb +5 -0
- data/redis-activesupport.gemspec +4 -2
- data/test/active_support/cache/redis_store_test.rb +40 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33df3ef09a75d9ce2b545efe032cd801d2437eea
|
4
|
+
data.tar.gz: 807b5a494112c947faaacd3c47090004e47ffc5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bdafb650c1a86020859524d0d9f66c3d9d6f2e1b6772525d05a9f6574fbfca702bdc9fbc404c1581ea94b06e9c2c7b309faf0c73f7d6a674197d1688ae2df3e
|
7
|
+
data.tar.gz: 1bd8ea70bc58ebfc4f89c2152590139bc516fea97e796fcdfd6657cacc78c53bc1e74ac522399bc1ebdca3ca783ee991ed9da8d5895285ce252635f06b950a66
|
data/.travis.yml
CHANGED
@@ -5,11 +5,11 @@ gemfile:
|
|
5
5
|
- gemfiles/Gemfile.activesupport-4.x
|
6
6
|
- gemfiles/Gemfile.activesupport-5.x
|
7
7
|
rvm:
|
8
|
-
-
|
9
|
-
- 2.
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
- 2.
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
11
|
+
- 2.3
|
12
|
+
- 2.4
|
13
13
|
- ruby-head
|
14
14
|
- jruby-head
|
15
15
|
services:
|
@@ -18,13 +18,7 @@ matrix:
|
|
18
18
|
allow_failures:
|
19
19
|
- rvm: jruby-head
|
20
20
|
- rvm: ruby-head
|
21
|
-
- rvm:
|
21
|
+
- rvm: 2.0
|
22
22
|
gemfile: gemfiles/Gemfile.activesupport-5.x
|
23
|
-
- rvm: 2.
|
24
|
-
gemfile: gemfiles/Gemfile.activesupport-5.x
|
25
|
-
- rvm: 2.1.5
|
26
|
-
gemfile: gemfiles/Gemfile.activesupport-5.x
|
27
|
-
- rvm: rbx-19mode
|
28
|
-
gemfile: gemfiles/Gemfile.activesupport-5.x
|
29
|
-
- rvm: jruby-19mode
|
23
|
+
- rvm: 2.1
|
30
24
|
gemfile: gemfiles/Gemfile.activesupport-5.x
|
@@ -4,6 +4,14 @@ require 'redis-store'
|
|
4
4
|
module ActiveSupport
|
5
5
|
module Cache
|
6
6
|
class RedisStore < Store
|
7
|
+
|
8
|
+
ERRORS_TO_RESCUE = [
|
9
|
+
Errno::ECONNREFUSED,
|
10
|
+
Errno::EHOSTUNREACH,
|
11
|
+
Redis::CannotConnectError,
|
12
|
+
Redis::ConnectionError
|
13
|
+
].freeze
|
14
|
+
|
7
15
|
attr_reader :data
|
8
16
|
|
9
17
|
# Instantiate the store.
|
@@ -82,7 +90,7 @@ module ActiveSupport
|
|
82
90
|
with do |store|
|
83
91
|
!(keys = store.keys(matcher)).empty? && store.del(*keys)
|
84
92
|
end
|
85
|
-
rescue
|
93
|
+
rescue *ERRORS_TO_RESCUE
|
86
94
|
raise if raise_errors?
|
87
95
|
false
|
88
96
|
end
|
@@ -103,12 +111,17 @@ module ActiveSupport
|
|
103
111
|
args = [keys, options]
|
104
112
|
args.flatten!
|
105
113
|
|
106
|
-
|
107
|
-
|
114
|
+
instrument(:read_multi, names) do |payload|
|
115
|
+
values = with { |c| c.mget(*args) }
|
116
|
+
values.map! { |v| v.is_a?(ActiveSupport::Cache::Entry) ? v.value : v }
|
108
117
|
|
109
|
-
|
110
|
-
|
111
|
-
|
118
|
+
Hash[names.zip(values)].reject{|k,v| v.nil?}.tap do |result|
|
119
|
+
payload[:hits] = result.keys if payload
|
120
|
+
end
|
121
|
+
end
|
122
|
+
rescue *ERRORS_TO_RESCUE
|
123
|
+
raise if raise_errors?
|
124
|
+
{}
|
112
125
|
end
|
113
126
|
|
114
127
|
def fetch_multi(*names)
|
@@ -128,12 +141,16 @@ module ActiveSupport
|
|
128
141
|
memo
|
129
142
|
end
|
130
143
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
144
|
+
begin
|
145
|
+
with do |c|
|
146
|
+
c.multi do
|
147
|
+
need_writes.each do |name, value|
|
148
|
+
write(name, value, options)
|
149
|
+
end
|
135
150
|
end
|
136
151
|
end
|
152
|
+
rescue *ERRORS_TO_RESCUE
|
153
|
+
raise if raise_errors?
|
137
154
|
end
|
138
155
|
|
139
156
|
fetched
|
@@ -234,7 +251,7 @@ module ActiveSupport
|
|
234
251
|
def write_entry(key, entry, options)
|
235
252
|
method = options && options[:unless_exist] ? :setnx : :set
|
236
253
|
with { |client| client.send method, key, entry, options }
|
237
|
-
rescue
|
254
|
+
rescue *ERRORS_TO_RESCUE
|
238
255
|
raise if raise_errors?
|
239
256
|
false
|
240
257
|
end
|
@@ -244,7 +261,7 @@ module ActiveSupport
|
|
244
261
|
if entry
|
245
262
|
entry.is_a?(ActiveSupport::Cache::Entry) ? entry : ActiveSupport::Cache::Entry.new(entry)
|
246
263
|
end
|
247
|
-
rescue
|
264
|
+
rescue *ERRORS_TO_RESCUE
|
248
265
|
raise if raise_errors?
|
249
266
|
nil
|
250
267
|
end
|
@@ -256,7 +273,7 @@ module ActiveSupport
|
|
256
273
|
#
|
257
274
|
def delete_entry(key, options)
|
258
275
|
with { |c| c.del key }
|
259
|
-
rescue
|
276
|
+
rescue *ERRORS_TO_RESCUE
|
260
277
|
raise if raise_errors?
|
261
278
|
false
|
262
279
|
end
|
data/redis-activesupport.gemspec
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path('../lib', __FILE__)
|
3
3
|
|
4
|
+
require 'redis/active_support/version'
|
5
|
+
|
4
6
|
Gem::Specification.new do |s|
|
5
7
|
s.name = 'redis-activesupport'
|
6
|
-
s.version =
|
8
|
+
s.version = Redis::ActiveSupport::VERSION
|
7
9
|
s.authors = ['Luca Guidi', 'Ryan Bigg']
|
8
10
|
s.email = ['me@lucaguidi.com', 'me@ryanbigg.com']
|
9
11
|
s.homepage = 'http://redis-store.org/redis-activesupport'
|
@@ -18,7 +20,7 @@ Gem::Specification.new do |s|
|
|
18
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
21
|
s.require_paths = ['lib']
|
20
22
|
|
21
|
-
s.add_runtime_dependency
|
23
|
+
s.add_runtime_dependency "redis-store", '>= 1.3', '< 2'
|
22
24
|
s.add_runtime_dependency 'activesupport', '>= 3', '< 6'
|
23
25
|
|
24
26
|
s.add_development_dependency 'rake', '~> 10'
|
@@ -585,6 +585,18 @@ describe ActiveSupport::Cache::RedisStore do
|
|
585
585
|
exist.payload.must_equal({ :key => 'the smiths' })
|
586
586
|
end
|
587
587
|
|
588
|
+
it "notifies on #read_multi" do
|
589
|
+
@store.write "depeche mode", "Enjoy The Silence"
|
590
|
+
|
591
|
+
with_notifications do
|
592
|
+
@store.read_multi "metallica", "depeche mode"
|
593
|
+
end
|
594
|
+
|
595
|
+
read = @events.first
|
596
|
+
read.name.must_equal('cache_read_multi.active_support')
|
597
|
+
read.payload.must_equal({ :key => ["metallica", "depeche mode"], :hits => ["depeche mode"] })
|
598
|
+
end
|
599
|
+
|
588
600
|
it "notifies on #delete_matched" do
|
589
601
|
with_notifications do
|
590
602
|
@store.delete_matched "afterhours*"
|
@@ -640,6 +652,20 @@ describe ActiveSupport::Cache::RedisStore do
|
|
640
652
|
end
|
641
653
|
end
|
642
654
|
|
655
|
+
it "raises on read_multi when redis is unavailable" do
|
656
|
+
assert_raises(Redis::CannotConnectError) do
|
657
|
+
@raise_error_store.read_multi("rabbit", "white-rabbit")
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
it "raises on fetch_multi when redis is unavailable" do
|
662
|
+
assert_raises(Redis::CannotConnectError) do
|
663
|
+
@raise_error_store.fetch_multi("rabbit", "white-rabbit") do |key|
|
664
|
+
key.upcase
|
665
|
+
end
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
643
669
|
it "raises on writes when redis is unavailable" do
|
644
670
|
assert_raises(Redis::CannotConnectError) do
|
645
671
|
@raise_error_store.write "rabbit", @white_rabbit, :expires_in => 1.second
|
@@ -665,10 +691,23 @@ describe ActiveSupport::Cache::RedisStore do
|
|
665
691
|
@raise_error_store.stubs(:with).raises(Redis::CannotConnectError)
|
666
692
|
end
|
667
693
|
|
668
|
-
it "
|
694
|
+
it "returns nil from read when redis is unavailable" do
|
669
695
|
@raise_error_store.read("rabbit").must_be_nil
|
670
696
|
end
|
671
697
|
|
698
|
+
it "returns empty hash from read_multi when redis is unavailable" do
|
699
|
+
@raise_error_store.read_multi("rabbit", "white-rabbit").must_equal({})
|
700
|
+
end
|
701
|
+
|
702
|
+
it "returns result hash from fetch_multi when redis is unavailable" do
|
703
|
+
@raise_error_store.fetch_multi("rabbit", "white-rabbit") do |key|
|
704
|
+
key.upcase
|
705
|
+
end.must_equal({
|
706
|
+
"rabbit" => "RABBIT",
|
707
|
+
"white-rabbit" => "WHITE-RABBIT",
|
708
|
+
})
|
709
|
+
end
|
710
|
+
|
672
711
|
it "returns false when redis is unavailable" do
|
673
712
|
@raise_error_store.write("rabbit", @white_rabbit, :expires_in => 1.second).must_equal(false)
|
674
713
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis-store
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
- - "<"
|
19
22
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
23
|
+
version: '2'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.3'
|
31
|
+
- - "<"
|
26
32
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
33
|
+
version: '2'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: activesupport
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,6 +160,7 @@ files:
|
|
154
160
|
- gemfiles/Gemfile.activesupport-5.x
|
155
161
|
- lib/active_support/cache/redis_store.rb
|
156
162
|
- lib/redis-activesupport.rb
|
163
|
+
- lib/redis/active_support/version.rb
|
157
164
|
- redis-activesupport.gemspec
|
158
165
|
- test/active_support/cache/redis_store_test.rb
|
159
166
|
- test/test_helper.rb
|