redis-activesupport 4.1.5 → 4.1.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +34 -0
- data/lib/active_support/cache/redis_store.rb +21 -13
- data/redis-activesupport.gemspec +1 -1
- data/test/active_support/cache/redis_store_test.rb +68 -2
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6919fcaa1c61e64d94d7cbcd20e320956c385247
|
4
|
+
data.tar.gz: 2528731435eb7102d7dd9ca9ec62253cad7ec2c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6684dfa22128db951fe854d82634b1c512c03605fc2f5b70f943293bb2228d8c051d33430c1e3a0d27670643a00847a4bdf0138f9525fb93393e90a70d48be7
|
7
|
+
data.tar.gz: 73d58c822be26ffb4cbe56137c26be9f3d28e4d1d7d859611e8c1664cb53abb5830361e8f60bb87c5e6b4faaeee147a2927fec530d51aad73e6dc723c16d78f8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -17,6 +17,40 @@ If you are using redis-store with Rails, consider using the [redis-rails gem](ht
|
|
17
17
|
ActiveSupport::Cache.lookup_store :redis_store # { ... optional configuration ... }
|
18
18
|
```
|
19
19
|
|
20
|
+
### Usage with Redis Sentinel
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
sentinel_config = {
|
24
|
+
url: "redis://mymaster/0",
|
25
|
+
role: "master",
|
26
|
+
sentinels: [{
|
27
|
+
host: "127.0.0.1",
|
28
|
+
port: 26379
|
29
|
+
},{
|
30
|
+
host: "127.0.0.1",
|
31
|
+
port: 26380
|
32
|
+
},{
|
33
|
+
host: "127.0.0.1",
|
34
|
+
port: 26381
|
35
|
+
}]
|
36
|
+
}
|
37
|
+
|
38
|
+
# configure cache, merging opts with sentinel conf
|
39
|
+
config.cache_store = :redis_store, sentinel_config.merge(
|
40
|
+
:namespace => "cache",
|
41
|
+
:expires_in => 1.days
|
42
|
+
)
|
43
|
+
|
44
|
+
# configure sessions, setting the sentinel config as the
|
45
|
+
# servers value, merging opts with the sentinel conf.
|
46
|
+
config.session_store :redis_store, {
|
47
|
+
:servers => sentinel_config.merge(
|
48
|
+
:namespace => "sessions"
|
49
|
+
),
|
50
|
+
:expires_in => 2.days
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
20
54
|
## Running tests
|
21
55
|
|
22
56
|
```shell
|
@@ -92,35 +92,43 @@ module ActiveSupport
|
|
92
92
|
# cache.read_multi "rabbit", "white-rabbit"
|
93
93
|
# cache.read_multi "rabbit", "white-rabbit", :raw => true
|
94
94
|
def read_multi(*names)
|
95
|
+
# Remove the options hash before mapping keys to values
|
95
96
|
options = names.extract_options!
|
97
|
+
return {} if names == []
|
98
|
+
|
96
99
|
keys = names.map{|name| namespaced_key(name, options)}
|
97
100
|
values = with { |c| c.mget(*keys) }
|
98
101
|
values.map! { |v| v.is_a?(ActiveSupport::Cache::Entry) ? v.value : v }
|
99
102
|
|
100
|
-
# Remove the options hash before mapping keys to values
|
101
|
-
names.extract_options!
|
102
|
-
|
103
103
|
result = Hash[keys.zip(values)]
|
104
104
|
result.reject!{ |k,v| v.nil? }
|
105
105
|
result
|
106
106
|
end
|
107
107
|
|
108
108
|
def fetch_multi(*names)
|
109
|
-
results = read_multi(*names)
|
110
109
|
options = names.extract_options!
|
110
|
+
return {} if names == []
|
111
|
+
|
112
|
+
results = read_multi(*names, options)
|
111
113
|
fetched = {}
|
112
114
|
|
115
|
+
need_writes = {}
|
116
|
+
|
117
|
+
fetched = names.inject({}) do |memo, name|
|
118
|
+
key = namespaced_key(name, options)
|
119
|
+
memo[key] = results.fetch(key) do
|
120
|
+
value = yield name
|
121
|
+
need_writes[name] = value
|
122
|
+
value
|
123
|
+
end
|
124
|
+
|
125
|
+
memo
|
126
|
+
end
|
127
|
+
|
113
128
|
with do |c|
|
114
129
|
c.multi do
|
115
|
-
|
116
|
-
|
117
|
-
memo[key] = results.fetch(key) do
|
118
|
-
value = yield name
|
119
|
-
write(name, value, options)
|
120
|
-
value
|
121
|
-
end
|
122
|
-
|
123
|
-
memo
|
130
|
+
need_writes.each do |name, value|
|
131
|
+
write(name, value, options)
|
124
132
|
end
|
125
133
|
end
|
126
134
|
end
|
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 = '4.1.
|
6
|
+
s.version = '4.1.6.pre'
|
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'
|
@@ -313,6 +313,16 @@ describe ActiveSupport::Cache::RedisStore do
|
|
313
313
|
result['namespaced:irish whisky'].must_equal("Jameson")
|
314
314
|
end
|
315
315
|
|
316
|
+
it "read_multi return an empty {} when given an empty array" do
|
317
|
+
result = @store.read_multi(*[])
|
318
|
+
result.must_equal({})
|
319
|
+
end
|
320
|
+
|
321
|
+
it "read_multi return an empty {} when given an empty array with option" do
|
322
|
+
result = @store.read_multi(*[], option: true)
|
323
|
+
result.must_equal({})
|
324
|
+
end
|
325
|
+
|
316
326
|
describe "fetch_multi" do
|
317
327
|
it "reads existing keys and fills in anything missing" do
|
318
328
|
@store.write "bourbon", "makers"
|
@@ -324,19 +334,75 @@ describe ActiveSupport::Cache::RedisStore do
|
|
324
334
|
result.must_equal({ "bourbon" => "makers", "rye" => "rye-was-missing" })
|
325
335
|
@store.read("rye").must_equal("rye-was-missing")
|
326
336
|
end
|
337
|
+
|
338
|
+
it "fetch command within fetch_multi block" do
|
339
|
+
@store.delete 'rye'
|
340
|
+
@store.write "bourbon", "makers"
|
341
|
+
|
342
|
+
result = @store.fetch_multi("bourbon", "rye") do |key|
|
343
|
+
@store.fetch "inner-#{key}" do
|
344
|
+
"#{key}-was-missing"
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
result.must_equal({ "bourbon" => "makers", "rye" => "rye-was-missing" })
|
349
|
+
@store.read("rye").must_equal("rye-was-missing")
|
350
|
+
@store.read("inner-rye").must_equal("rye-was-missing")
|
351
|
+
end
|
352
|
+
|
353
|
+
it "return an empty {} when given an empty array" do
|
354
|
+
result = @store.fetch_multi(*[]) { 1 }
|
355
|
+
result.must_equal({})
|
356
|
+
end
|
357
|
+
|
358
|
+
it "return an empty {} when given an empty array with option" do
|
359
|
+
result = @store.fetch_multi(*[], option: true)
|
360
|
+
result.must_equal({})
|
361
|
+
end
|
327
362
|
end
|
328
363
|
|
329
364
|
describe "fetch_multi namespaced keys" do
|
330
365
|
it "reads existing keys and fills in anything missing" do
|
331
|
-
@store.write "bourbon", "makers", namespace:'namespaced'
|
366
|
+
@store.write "bourbon", "makers", namespace: 'namespaced'
|
332
367
|
|
333
|
-
result = @store.fetch_multi("bourbon", "rye", namespace:'namespaced') do |key|
|
368
|
+
result = @store.fetch_multi("bourbon", "rye", namespace: 'namespaced') do |key|
|
334
369
|
"#{key}-was-missing"
|
335
370
|
end
|
336
371
|
|
337
372
|
result.must_equal({ "namespaced:bourbon" => "makers", "namespaced:rye" => "rye-was-missing" })
|
338
373
|
@store.read("namespaced:rye").must_equal("rye-was-missing")
|
339
374
|
end
|
375
|
+
|
376
|
+
it "fetch command within fetch_multi block" do
|
377
|
+
@store.delete 'namespaced:rye'
|
378
|
+
@store.write "bourbon", "makers", namespace: 'namespaced'
|
379
|
+
|
380
|
+
result = @store.fetch_multi("bourbon", "rye", namespace: 'namespaced') do |key|
|
381
|
+
@store.fetch "namespaced:inner-#{key}" do
|
382
|
+
"#{key}-was-missing"
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
result.must_equal({ "namespaced:bourbon" => "makers", "namespaced:rye" => "rye-was-missing" })
|
387
|
+
@store.read("namespaced:rye").must_equal("rye-was-missing")
|
388
|
+
@store.read("namespaced:inner-rye").must_equal("rye-was-missing")
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
describe "fetch_multi nested keys" do
|
393
|
+
it "reads existing keys and fills in anything missing" do
|
394
|
+
@store.write ["bourbon", "bourbon-extended"], "makers"
|
395
|
+
|
396
|
+
bourbon_key = ["bourbon", "bourbon-extended"]
|
397
|
+
rye_key = ["rye", "rye-extended"]
|
398
|
+
|
399
|
+
result = @store.fetch_multi(bourbon_key, rye_key) do |key|
|
400
|
+
"#{key}-was-missing"
|
401
|
+
end
|
402
|
+
|
403
|
+
result.must_equal({ "bourbon/bourbon-extended" => "makers", "rye/rye-extended" => "#{rye_key}-was-missing" })
|
404
|
+
@store.read(rye_key).must_equal("#{rye_key}-was-missing")
|
405
|
+
end
|
340
406
|
end
|
341
407
|
|
342
408
|
describe "notifications" 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: 4.1.
|
4
|
+
version: 4.1.6.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -9,124 +9,124 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-31 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.1.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.1.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: '5'
|
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: '5'
|
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
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '4.2'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: connection_pool
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.2.0
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.2.0
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: redis-store-testing
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
description: Redis store for ActiveSupport
|
@@ -137,8 +137,8 @@ executables: []
|
|
137
137
|
extensions: []
|
138
138
|
extra_rdoc_files: []
|
139
139
|
files:
|
140
|
-
-
|
141
|
-
-
|
140
|
+
- .gitignore
|
141
|
+
- .travis.yml
|
142
142
|
- Gemfile
|
143
143
|
- MIT-LICENSE
|
144
144
|
- README.md
|
@@ -160,17 +160,17 @@ require_paths:
|
|
160
160
|
- lib
|
161
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- -
|
163
|
+
- - '>='
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - '>'
|
169
169
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
170
|
+
version: 1.3.1
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project: redis-activesupport
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.5.2
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Redis store for ActiveSupport
|