redis-store 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redis-store might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +1 -3
- data/README.md +5 -21
- data/lib/redis-store.rb +2 -2
- data/lib/redis/distributed_store.rb +5 -1
- data/lib/redis/store/factory.rb +95 -0
- data/lib/redis/store/marshalling.rb +2 -1
- data/lib/redis/store/version.rb +1 -1
- data/redis-store.gemspec +8 -9
- data/test/config/node-one.conf +17 -388
- data/test/config/node-two.conf +17 -388
- data/test/config/redis.conf +17 -389
- data/test/redis/{factory_test.rb → store/factory_test.rb} +52 -16
- data/test/redis/store/marshalling_test.rb +3 -3
- data/test/redis/store/version_test.rb +2 -2
- data/test/test_helper.rb +2 -4
- metadata +25 -57
- data/lib/redis/factory.rb +0 -41
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
describe "Redis::Factory" do
|
3
|
+
describe "Redis::Store::Factory" do
|
4
4
|
describe ".create" do
|
5
5
|
describe "when not given any arguments" do
|
6
6
|
it "instantiates Redis::Store" do
|
7
|
-
store = Redis::Factory.create
|
7
|
+
store = Redis::Store::Factory.create
|
8
8
|
store.must_be_kind_of(Redis::Store)
|
9
9
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
|
10
10
|
end
|
@@ -12,42 +12,42 @@ describe "Redis::Factory" do
|
|
12
12
|
|
13
13
|
describe "when given a Hash" do
|
14
14
|
it "uses specified host" do
|
15
|
-
store = Redis::Factory.create :host => "localhost"
|
15
|
+
store = Redis::Store::Factory.create :host => "localhost"
|
16
16
|
store.to_s.must_equal("Redis Client connected to localhost:6379 against DB 0")
|
17
17
|
end
|
18
18
|
|
19
19
|
it "uses specified port" do
|
20
|
-
store = Redis::Factory.create :host => "localhost", :port => 6380
|
20
|
+
store = Redis::Store::Factory.create :host => "localhost", :port => 6380
|
21
21
|
store.to_s.must_equal("Redis Client connected to localhost:6380 against DB 0")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "uses specified db" do
|
25
|
-
store = Redis::Factory.create :host => "localhost", :port => 6380, :db => 13
|
25
|
+
store = Redis::Store::Factory.create :host => "localhost", :port => 6380, :db => 13
|
26
26
|
store.to_s.must_equal("Redis Client connected to localhost:6380 against DB 13")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "uses specified namespace" do
|
30
|
-
store = Redis::Factory.create :namespace => "theplaylist"
|
30
|
+
store = Redis::Store::Factory.create :namespace => "theplaylist"
|
31
31
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "uses specified key_prefix as namespace" do
|
35
|
-
store = Redis::Factory.create :key_prefix => "theplaylist"
|
35
|
+
store = Redis::Store::Factory.create :key_prefix => "theplaylist"
|
36
36
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
|
37
37
|
end
|
38
38
|
|
39
39
|
it "uses specified password" do
|
40
|
-
store = Redis::Factory.create :password => "secret"
|
40
|
+
store = Redis::Store::Factory.create :password => "secret"
|
41
41
|
store.instance_variable_get(:@client).password.must_equal("secret")
|
42
42
|
end
|
43
43
|
|
44
44
|
it "allows/disable marshalling" do
|
45
|
-
store = Redis::Factory.create :marshalling => false
|
45
|
+
store = Redis::Store::Factory.create :marshalling => false
|
46
46
|
store.instance_variable_get(:@marshalling).must_equal(false)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should instantiate a Redis::DistributedStore store" do
|
50
|
-
store = Redis::Factory.create(
|
50
|
+
store = Redis::Store::Factory.create(
|
51
51
|
{:host => "localhost", :port => 6379},
|
52
52
|
{:host => "localhost", :port => 6380}
|
53
53
|
)
|
@@ -61,32 +61,32 @@ describe "Redis::Factory" do
|
|
61
61
|
|
62
62
|
describe "when given a String" do
|
63
63
|
it "uses specified host" do
|
64
|
-
store = Redis::Factory.create "redis://127.0.0.1"
|
64
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1"
|
65
65
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0")
|
66
66
|
end
|
67
67
|
|
68
68
|
it "uses specified port" do
|
69
|
-
store = Redis::Factory.create "redis://127.0.0.1:6380"
|
69
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1:6380"
|
70
70
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6380 against DB 0")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "uses specified db" do
|
74
|
-
store = Redis::Factory.create "redis://127.0.0.1:6380/13"
|
74
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1:6380/13"
|
75
75
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6380 against DB 13")
|
76
76
|
end
|
77
77
|
|
78
78
|
it "uses specified namespace" do
|
79
|
-
store = Redis::Factory.create "redis://127.0.0.1:6379/0/theplaylist"
|
79
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist"
|
80
80
|
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "uses specified password" do
|
84
|
-
store = Redis::Factory.create "redis://:secret@127.0.0.1:6379/0/theplaylist"
|
84
|
+
store = Redis::Store::Factory.create "redis://:secret@127.0.0.1:6379/0/theplaylist"
|
85
85
|
store.instance_variable_get(:@client).password.must_equal("secret")
|
86
86
|
end
|
87
87
|
|
88
88
|
it "instantiates Redis::DistributedStore" do
|
89
|
-
store = Redis::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380"
|
89
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380"
|
90
90
|
store.must_be_kind_of(Redis::DistributedStore)
|
91
91
|
store.nodes.map {|node| node.to_s }.must_equal([
|
92
92
|
"Redis Client connected to 127.0.0.1:6379 against DB 0",
|
@@ -94,5 +94,41 @@ describe "Redis::Factory" do
|
|
94
94
|
])
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
describe 'when given host Hash and options Hash' do
|
99
|
+
it 'instantiates Redis::Store and merges options' do
|
100
|
+
store = Redis::Store::Factory.create(
|
101
|
+
{ :host => '127.0.0.1', :port => '6379' },
|
102
|
+
{ :namespace => 'theplaylist' }
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'instantiates Redis::DistributedStore and merges options' do
|
107
|
+
store = Redis::Store::Factory.create(
|
108
|
+
{ :host => '127.0.0.1', :port => '6379' },
|
109
|
+
{ :host => '127.0.0.1', :port => '6380' },
|
110
|
+
{ :namespace => 'theplaylist' }
|
111
|
+
)
|
112
|
+
store.nodes.map {|node| node.to_s }.must_equal([
|
113
|
+
"Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
|
114
|
+
"Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist"
|
115
|
+
])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'when given host String and options Hash' do
|
120
|
+
it 'instantiates Redis::Store and merges options' do
|
121
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1", { :namespace => 'theplaylist' }
|
122
|
+
store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'instantiates Redis::DistributedStore and merges options' do
|
126
|
+
store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380", { :namespace => 'theplaylist' }
|
127
|
+
store.nodes.map {|node| node.to_s }.must_equal([
|
128
|
+
"Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
|
129
|
+
"Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist",
|
130
|
+
])
|
131
|
+
end
|
132
|
+
end
|
97
133
|
end
|
98
134
|
end
|
@@ -28,7 +28,7 @@ describe "Redis::Marshalling" do
|
|
28
28
|
end
|
29
29
|
else
|
30
30
|
it "doesn't unmarshal on get if raw option is true" do
|
31
|
-
@store.get("rabbit", :raw => true).
|
31
|
+
@store.get("rabbit", :raw => true).must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -84,8 +84,8 @@ describe "Redis::Marshalling" do
|
|
84
84
|
it "doesn't unmarshal on multi get if raw option is true" do
|
85
85
|
@store.set "rabbit2", @white_rabbit
|
86
86
|
rabbit, rabbit2 = @store.mget "rabbit", "rabbit2", :raw => true
|
87
|
-
rabbit.
|
88
|
-
rabbit2.
|
87
|
+
rabbit.must_include("\x04\bU:\x0FOpenStruct{\x06:\tname")
|
88
|
+
rabbit2.must_include("\x04\bU:\x0FOpenStruct{\x06:\ncolor")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,129 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Luca Guidi
|
9
|
-
- Matt Horan
|
10
8
|
autorequire:
|
11
9
|
bindir: bin
|
12
10
|
cert_chain: []
|
13
|
-
date:
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
name: redis
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
16
|
requirements:
|
20
|
-
- -
|
17
|
+
- - '>='
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.2
|
19
|
+
version: '2.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
23
|
requirements:
|
28
|
-
- -
|
24
|
+
- - '>='
|
29
25
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.2
|
26
|
+
version: '2.2'
|
31
27
|
- !ruby/object:Gem::Dependency
|
32
28
|
name: rake
|
33
29
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
30
|
requirements:
|
36
31
|
- - ~>
|
37
32
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
33
|
+
version: '10'
|
39
34
|
type: :development
|
40
35
|
prerelease: false
|
41
36
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
37
|
requirements:
|
44
38
|
- - ~>
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: '10'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: bundler
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
44
|
requirements:
|
52
45
|
- - ~>
|
53
46
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
47
|
+
version: '1.3'
|
55
48
|
type: :development
|
56
49
|
prerelease: false
|
57
50
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
51
|
requirements:
|
60
52
|
- - ~>
|
61
53
|
- !ruby/object:Gem::Version
|
62
|
-
version: '1.
|
54
|
+
version: '1.3'
|
63
55
|
- !ruby/object:Gem::Dependency
|
64
56
|
name: mocha
|
65
57
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
58
|
requirements:
|
68
59
|
- - ~>
|
69
60
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0.
|
61
|
+
version: 0.14.0
|
71
62
|
type: :development
|
72
63
|
prerelease: false
|
73
64
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
65
|
requirements:
|
76
66
|
- - ~>
|
77
67
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.
|
68
|
+
version: 0.14.0
|
79
69
|
- !ruby/object:Gem::Dependency
|
80
70
|
name: minitest
|
81
71
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
72
|
requirements:
|
84
73
|
- - ~>
|
85
74
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
75
|
+
version: '5'
|
87
76
|
type: :development
|
88
77
|
prerelease: false
|
89
78
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
79
|
requirements:
|
92
80
|
- - ~>
|
93
81
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: purdytest
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
|
-
requirements:
|
100
|
-
- - ~>
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 1.0.0
|
103
|
-
type: :development
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
|
-
requirements:
|
108
|
-
- - ~>
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0.0
|
82
|
+
version: '5'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: git
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
86
|
requirements:
|
116
87
|
- - ~>
|
117
88
|
- !ruby/object:Gem::Version
|
118
|
-
version: 1.2
|
89
|
+
version: '1.2'
|
119
90
|
type: :development
|
120
91
|
prerelease: false
|
121
92
|
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
93
|
requirements:
|
124
94
|
- - ~>
|
125
95
|
- !ruby/object:Gem::Version
|
126
|
-
version: 1.2
|
96
|
+
version: '1.2'
|
127
97
|
description: Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for
|
128
98
|
Ruby web frameworks.
|
129
99
|
email:
|
@@ -138,8 +108,8 @@ files:
|
|
138
108
|
- Rakefile
|
139
109
|
- lib/redis-store.rb
|
140
110
|
- lib/redis/distributed_store.rb
|
141
|
-
- lib/redis/factory.rb
|
142
111
|
- lib/redis/store.rb
|
112
|
+
- lib/redis/store/factory.rb
|
143
113
|
- lib/redis/store/interface.rb
|
144
114
|
- lib/redis/store/marshalling.rb
|
145
115
|
- lib/redis/store/namespace.rb
|
@@ -151,7 +121,7 @@ files:
|
|
151
121
|
- test/config/node-two.conf
|
152
122
|
- test/config/redis.conf
|
153
123
|
- test/redis/distributed_store_test.rb
|
154
|
-
- test/redis/factory_test.rb
|
124
|
+
- test/redis/store/factory_test.rb
|
155
125
|
- test/redis/store/interface_test.rb
|
156
126
|
- test/redis/store/marshalling_test.rb
|
157
127
|
- test/redis/store/namespace_test.rb
|
@@ -159,36 +129,35 @@ files:
|
|
159
129
|
- test/redis/store/version_test.rb
|
160
130
|
- test/redis/store_test.rb
|
161
131
|
- test/test_helper.rb
|
162
|
-
homepage: http://
|
132
|
+
homepage: http://redis-store.org/redis-store
|
163
133
|
licenses: []
|
134
|
+
metadata: {}
|
164
135
|
post_install_message:
|
165
136
|
rdoc_options: []
|
166
137
|
require_paths:
|
167
138
|
- lib
|
168
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
140
|
requirements:
|
171
|
-
- -
|
141
|
+
- - '>='
|
172
142
|
- !ruby/object:Gem::Version
|
173
143
|
version: '0'
|
174
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
145
|
requirements:
|
177
|
-
- -
|
146
|
+
- - '>='
|
178
147
|
- !ruby/object:Gem::Version
|
179
148
|
version: '0'
|
180
149
|
requirements: []
|
181
150
|
rubyforge_project: redis-store
|
182
|
-
rubygems_version:
|
151
|
+
rubygems_version: 2.0.3
|
183
152
|
signing_key:
|
184
|
-
specification_version:
|
153
|
+
specification_version: 4
|
185
154
|
summary: Redis stores for Ruby frameworks
|
186
155
|
test_files:
|
187
156
|
- test/config/node-one.conf
|
188
157
|
- test/config/node-two.conf
|
189
158
|
- test/config/redis.conf
|
190
159
|
- test/redis/distributed_store_test.rb
|
191
|
-
- test/redis/factory_test.rb
|
160
|
+
- test/redis/store/factory_test.rb
|
192
161
|
- test/redis/store/interface_test.rb
|
193
162
|
- test/redis/store/marshalling_test.rb
|
194
163
|
- test/redis/store/namespace_test.rb
|
@@ -196,4 +165,3 @@ test_files:
|
|
196
165
|
- test/redis/store/version_test.rb
|
197
166
|
- test/redis/store_test.rb
|
198
167
|
- test/test_helper.rb
|
199
|
-
has_rdoc:
|
data/lib/redis/factory.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
|
-
class Redis
|
4
|
-
class Factory
|
5
|
-
def self.create(*redis_client_options)
|
6
|
-
redis_client_options = redis_client_options.flatten.compact.inject([]) do |result, address|
|
7
|
-
result << resolve(address)
|
8
|
-
result
|
9
|
-
end
|
10
|
-
if redis_client_options.size > 1
|
11
|
-
::Redis::DistributedStore.new redis_client_options
|
12
|
-
else
|
13
|
-
::Redis::Store.new redis_client_options.first || {}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.resolve(uri) #:api: private
|
18
|
-
if uri.is_a?(Hash)
|
19
|
-
options = uri.dup
|
20
|
-
options[:namespace] ||= options.delete(:key_prefix) # RailsSessionStore
|
21
|
-
options
|
22
|
-
else
|
23
|
-
uri = URI.parse(uri)
|
24
|
-
_, db, namespace = if uri.path
|
25
|
-
uri.path.split /\//
|
26
|
-
end
|
27
|
-
|
28
|
-
options = {
|
29
|
-
:host => uri.host,
|
30
|
-
:port => uri.port || 6379,
|
31
|
-
:password => uri.password
|
32
|
-
}
|
33
|
-
|
34
|
-
options[:db] = db.to_i if db
|
35
|
-
options[:namespace] = namespace if namespace
|
36
|
-
|
37
|
-
options
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|