redis-activesupport 5.0.2 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/active_support/cache/redis_store.rb +16 -23
- data/redis-activesupport.gemspec +1 -1
- data/test/active_support/cache/redis_store_test.rb +31 -1
- metadata +27 -28
- data/stdout +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eebc0d644eba5c56ef06413a98ac47d8cf73539f
|
4
|
+
data.tar.gz: 33b363c215491c97282d37f596068868ba484313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a357ae2389638487bc51e9b976f3d76df74765096f91b0d9fbd9cda5eda6720afb3014a3867c77a5633f0cc6993901ffe739738774a7e085942c432f1f134239
|
7
|
+
data.tar.gz: a986a0f70541447333c59c0ad1c034c59ab9aaa71d6b2ddc634330973193572bbfa7d95c6bb77d0aa2828f0f5949a4c74b5989820e322fa0861ec308bfd7e9d7
|
data/.gitignore
CHANGED
@@ -67,13 +67,10 @@ module ActiveSupport
|
|
67
67
|
|
68
68
|
# Delete objects for matched keys.
|
69
69
|
#
|
70
|
-
# Uses SCAN to iterate and collect matched keys only when both client and
|
71
|
-
# server supports it (Redis server >= 2.8.0, client >= 3.0.6)
|
72
|
-
#
|
73
70
|
# Performance note: this operation can be dangerous for large production
|
74
|
-
# databases
|
75
|
-
#
|
76
|
-
#
|
71
|
+
# databases, as it uses the Redis "KEYS" command, which is O(N) over the
|
72
|
+
# total number of keys in the database. Users of large Redis caches should
|
73
|
+
# avoid this method.
|
77
74
|
#
|
78
75
|
# Example:
|
79
76
|
# cache.delete_matched "rab*"
|
@@ -83,17 +80,7 @@ module ActiveSupport
|
|
83
80
|
matcher = key_matcher(matcher, options)
|
84
81
|
begin
|
85
82
|
with do |store|
|
86
|
-
|
87
|
-
store.supports_redis_version?("2.8.0") &&
|
88
|
-
store.respond_to?(:scan_each)
|
89
|
-
|
90
|
-
if supports_scan_each
|
91
|
-
keys = store.scan_each(match: matcher).to_a
|
92
|
-
else
|
93
|
-
keys = store.keys(matcher)
|
94
|
-
end
|
95
|
-
|
96
|
-
!keys.empty? && store.del(*keys)
|
83
|
+
!(keys = store.keys(matcher)).empty? && store.del(*keys)
|
97
84
|
end
|
98
85
|
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Redis::CannotConnectError
|
99
86
|
raise if raise_errors?
|
@@ -109,10 +96,14 @@ module ActiveSupport
|
|
109
96
|
# cache.read_multi "rabbit", "white-rabbit"
|
110
97
|
# cache.read_multi "rabbit", "white-rabbit", :raw => true
|
111
98
|
def read_multi(*names)
|
112
|
-
return {} if names == []
|
113
99
|
options = names.extract_options!
|
100
|
+
return {} if names == []
|
101
|
+
|
114
102
|
keys = names.map{|name| normalize_key(name, options)}
|
115
|
-
|
103
|
+
args = [keys, options]
|
104
|
+
args.flatten!
|
105
|
+
|
106
|
+
values = with { |c| c.mget(*args) }
|
116
107
|
values.map! { |v| v.is_a?(ActiveSupport::Cache::Entry) ? v.value : v }
|
117
108
|
|
118
109
|
result = Hash[names.zip(values)]
|
@@ -121,9 +112,10 @@ module ActiveSupport
|
|
121
112
|
end
|
122
113
|
|
123
114
|
def fetch_multi(*names)
|
124
|
-
return {} if names == []
|
125
|
-
results = read_multi(*names)
|
126
115
|
options = names.extract_options!
|
116
|
+
return {} if names == []
|
117
|
+
|
118
|
+
results = read_multi(*names, options)
|
127
119
|
need_writes = {}
|
128
120
|
|
129
121
|
fetched = names.inject({}) do |memo, name|
|
@@ -273,7 +265,6 @@ module ActiveSupport
|
|
273
265
|
!!@options[:raise_errors]
|
274
266
|
end
|
275
267
|
|
276
|
-
|
277
268
|
# Add the namespace defined in the options to a pattern designed to match keys.
|
278
269
|
#
|
279
270
|
# This implementation is __different__ than ActiveSupport:
|
@@ -281,8 +272,10 @@ module ActiveSupport
|
|
281
272
|
# only for strings with wildcards.
|
282
273
|
def key_matcher(pattern, options)
|
283
274
|
prefix = options[:namespace].is_a?(Proc) ? options[:namespace].call : options[:namespace]
|
275
|
+
|
276
|
+
pattern = pattern.inspect[1..-2] if pattern.is_a? Regexp
|
277
|
+
|
284
278
|
if prefix
|
285
|
-
raise "Regexps aren't supported, please use string with wildcards." if pattern.is_a?(Regexp)
|
286
279
|
"#{prefix}:#{pattern}"
|
287
280
|
else
|
288
281
|
pattern
|
data/redis-activesupport.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'redis-activesupport'
|
6
|
-
s.version = '5.0.
|
6
|
+
s.version = '5.0.3'
|
7
7
|
s.authors = ['Luca Guidi', 'Ryan Bigg']
|
8
8
|
s.email = ['me@lucaguidi.com', 'me@ryanbigg.com']
|
9
9
|
s.homepage = 'http://redis-store.org/redis-activesupport'
|
@@ -176,7 +176,7 @@ describe ActiveSupport::Cache::RedisStore do
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
if RUBY_VERSION.match
|
179
|
+
if RUBY_VERSION.match(/1\.9/)
|
180
180
|
it "reads raw data" do
|
181
181
|
with_store_management do |store|
|
182
182
|
result = store.read("rabbit", :raw => true)
|
@@ -227,6 +227,18 @@ describe ActiveSupport::Cache::RedisStore do
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
|
+
it 'deletes matched data with a regexp' do
|
231
|
+
with_store_management do |store|
|
232
|
+
store.write "rabbit2", @white_rabbit
|
233
|
+
store.write "rub-a-dub", "Flora de Cana"
|
234
|
+
store.delete_matched(/rabb*/)
|
235
|
+
|
236
|
+
store.read("rabbit").must_be_nil
|
237
|
+
store.read("rabbit2").must_be_nil
|
238
|
+
store.exist?("rub-a-dub").must_equal(true)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
230
242
|
it "verifies existence of an object in the store" do
|
231
243
|
with_store_management do |store|
|
232
244
|
store.exist?("rabbit").must_equal(true)
|
@@ -415,6 +427,19 @@ describe ActiveSupport::Cache::RedisStore do
|
|
415
427
|
result.must_equal({})
|
416
428
|
end
|
417
429
|
|
430
|
+
it "read_multi return an empty {} when given an empty array with option" do
|
431
|
+
result = @store.read_multi(*[], option: true)
|
432
|
+
result.must_equal({})
|
433
|
+
end
|
434
|
+
|
435
|
+
it "read_multi returns values with raw option" do
|
436
|
+
@store.write "raw-value-a", "A", raw: true
|
437
|
+
@store.write "raw-value-b", "B", raw: true
|
438
|
+
|
439
|
+
result = @store.read_multi("raw-value-a", "raw-value-b", :raw => true)
|
440
|
+
result.must_equal({ "raw-value-a" => "A", "raw-value-b" => "B" })
|
441
|
+
end
|
442
|
+
|
418
443
|
describe "fetch_multi" do
|
419
444
|
it "reads existing keys and fills in anything missing" do
|
420
445
|
@store.write "bourbon", "makers"
|
@@ -446,6 +471,11 @@ describe ActiveSupport::Cache::RedisStore do
|
|
446
471
|
result = @store.fetch_multi(*[]) { 1 }
|
447
472
|
result.must_equal({})
|
448
473
|
end
|
474
|
+
|
475
|
+
it "return an empty {} when given an empty array with option" do
|
476
|
+
result = @store.read_multi(*[], option: true)
|
477
|
+
result.must_equal({})
|
478
|
+
end
|
449
479
|
end
|
450
480
|
|
451
481
|
describe "fetch_multi namespaced keys" do
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -9,130 +9,130 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-10 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
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.3.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.3.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '3'
|
35
|
-
- - <
|
35
|
+
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '6'
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '3'
|
45
|
-
- - <
|
45
|
+
- - "<"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '6'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bundler
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.3'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: mocha
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.14.0
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 0.14.0
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: minitest
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '4.2'
|
97
|
-
- - <
|
97
|
+
- - "<"
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '6'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
102
|
version_requirements: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '4.2'
|
107
|
-
- - <
|
107
|
+
- - "<"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '6'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: connection_pool
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - ~>
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 2.2.0
|
117
117
|
type: :development
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- - ~>
|
121
|
+
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: 2.2.0
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: redis-store-testing
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- -
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
type: :development
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- -
|
135
|
+
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
description: Redis store for ActiveSupport
|
@@ -143,8 +143,8 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
-
- .gitignore
|
147
|
-
- .travis.yml
|
146
|
+
- ".gitignore"
|
147
|
+
- ".travis.yml"
|
148
148
|
- Gemfile
|
149
149
|
- MIT-LICENSE
|
150
150
|
- README.md
|
@@ -155,7 +155,6 @@ files:
|
|
155
155
|
- lib/active_support/cache/redis_store.rb
|
156
156
|
- lib/redis-activesupport.rb
|
157
157
|
- redis-activesupport.gemspec
|
158
|
-
- stdout
|
159
158
|
- test/active_support/cache/redis_store_test.rb
|
160
159
|
- test/test_helper.rb
|
161
160
|
homepage: http://redis-store.org/redis-activesupport
|
@@ -168,17 +167,17 @@ require_paths:
|
|
168
167
|
- lib
|
169
168
|
required_ruby_version: !ruby/object:Gem::Requirement
|
170
169
|
requirements:
|
171
|
-
- -
|
170
|
+
- - ">="
|
172
171
|
- !ruby/object:Gem::Version
|
173
172
|
version: '0'
|
174
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
174
|
requirements:
|
176
|
-
- -
|
175
|
+
- - ">="
|
177
176
|
- !ruby/object:Gem::Version
|
178
177
|
version: '0'
|
179
178
|
requirements: []
|
180
179
|
rubyforge_project: redis-activesupport
|
181
|
-
rubygems_version: 2.
|
180
|
+
rubygems_version: 2.6.11
|
182
181
|
signing_key:
|
183
182
|
specification_version: 4
|
184
183
|
summary: Redis store for ActiveSupport
|
data/stdout
DELETED
File without changes
|