redis 3.0.0.rc1 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +50 -0
- data/.travis/Gemfile +11 -0
- data/CHANGELOG.md +47 -19
- data/README.md +160 -149
- data/Rakefile +15 -50
- data/examples/pubsub.rb +1 -1
- data/examples/unicorn/config.ru +1 -1
- data/examples/unicorn/unicorn.rb +1 -1
- data/lib/redis.rb +790 -390
- data/lib/redis/client.rb +137 -49
- data/lib/redis/connection/hiredis.rb +26 -15
- data/lib/redis/connection/ruby.rb +170 -53
- data/lib/redis/connection/synchrony.rb +23 -35
- data/lib/redis/distributed.rb +92 -32
- data/lib/redis/errors.rb +4 -2
- data/lib/redis/pipeline.rb +17 -6
- data/lib/redis/version.rb +1 -1
- data/redis.gemspec +4 -6
- data/test/blocking_commands_test.rb +42 -0
- data/test/command_map_test.rb +18 -17
- data/test/commands_on_hashes_test.rb +13 -12
- data/test/commands_on_lists_test.rb +35 -45
- data/test/commands_on_sets_test.rb +55 -54
- data/test/commands_on_sorted_sets_test.rb +106 -105
- data/test/commands_on_strings_test.rb +64 -55
- data/test/commands_on_value_types_test.rb +66 -54
- data/test/connection_handling_test.rb +136 -151
- data/test/distributed_blocking_commands_test.rb +33 -40
- data/test/distributed_commands_on_hashes_test.rb +6 -7
- data/test/distributed_commands_on_lists_test.rb +13 -14
- data/test/distributed_commands_on_sets_test.rb +57 -58
- data/test/distributed_commands_on_sorted_sets_test.rb +11 -12
- data/test/distributed_commands_on_strings_test.rb +31 -32
- data/test/distributed_commands_on_value_types_test.rb +61 -46
- data/test/distributed_commands_requiring_clustering_test.rb +108 -108
- data/test/distributed_connection_handling_test.rb +14 -15
- data/test/distributed_internals_test.rb +7 -19
- data/test/distributed_key_tags_test.rb +36 -36
- data/test/distributed_persistence_control_commands_test.rb +17 -14
- data/test/distributed_publish_subscribe_test.rb +61 -69
- data/test/distributed_remote_server_control_commands_test.rb +39 -28
- data/test/distributed_sorting_test.rb +12 -13
- data/test/distributed_test.rb +40 -41
- data/test/distributed_transactions_test.rb +20 -21
- data/test/encoding_test.rb +12 -9
- data/test/error_replies_test.rb +42 -36
- data/test/helper.rb +118 -85
- data/test/helper_test.rb +20 -6
- data/test/internals_test.rb +167 -103
- data/test/lint/blocking_commands.rb +124 -0
- data/test/lint/hashes.rb +115 -93
- data/test/lint/lists.rb +86 -80
- data/test/lint/sets.rb +68 -62
- data/test/lint/sorted_sets.rb +200 -195
- data/test/lint/strings.rb +112 -94
- data/test/lint/value_types.rb +76 -55
- data/test/persistence_control_commands_test.rb +17 -12
- data/test/pipelining_commands_test.rb +135 -126
- data/test/publish_subscribe_test.rb +105 -110
- data/test/remote_server_control_commands_test.rb +74 -58
- data/test/sorting_test.rb +31 -29
- data/test/support/connection/hiredis.rb +1 -0
- data/test/support/connection/ruby.rb +1 -0
- data/test/support/connection/synchrony.rb +17 -0
- data/test/{redis_mock.rb → support/redis_mock.rb} +24 -21
- data/test/support/wire/synchrony.rb +24 -0
- data/test/support/wire/thread.rb +5 -0
- data/test/synchrony_driver.rb +9 -9
- data/test/test.conf +1 -1
- data/test/thread_safety_test.rb +21 -19
- data/test/transactions_test.rb +189 -118
- data/test/unknown_commands_test.rb +9 -8
- data/test/url_param_test.rb +46 -41
- metadata +28 -43
- data/TODO.md +0 -4
- data/benchmarking/thread_safety.rb +0 -38
- data/test/lint/internals.rb +0 -36
@@ -1,13 +1,14 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "helper"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class TestUnknownCommands < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Helper::Client
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def test_should_try_to_work
|
10
|
+
assert_raise Redis::CommandError do
|
11
|
+
r.not_yet_implemented_command
|
12
|
+
end
|
12
13
|
end
|
13
14
|
end
|
data/test/url_param_test.rb
CHANGED
@@ -1,59 +1,64 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "helper"
|
4
4
|
|
5
|
-
|
6
|
-
redis = Redis.connect
|
5
|
+
class TestUrlParam < Test::Unit::TestCase
|
7
6
|
|
8
|
-
|
9
|
-
assert 6379 == redis.client.port
|
10
|
-
assert 0 == redis.client.db
|
11
|
-
assert nil == redis.client.password
|
12
|
-
end
|
7
|
+
include Helper::Client
|
13
8
|
|
14
|
-
|
15
|
-
|
9
|
+
def test_url_defaults_to_______________
|
10
|
+
redis = Redis.new
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
12
|
+
assert_equal "127.0.0.1", redis.client.host
|
13
|
+
assert_equal 6379, redis.client.port
|
14
|
+
assert_equal 0, redis.client.db
|
15
|
+
assert_equal nil, redis.client.password
|
16
|
+
end
|
22
17
|
|
23
|
-
|
24
|
-
|
18
|
+
def test_allows_to_pass_in_a_url
|
19
|
+
redis = Redis.new :url => "redis://:secr3t@foo.com:999/2"
|
25
20
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
assert_equal "foo.com", redis.client.host
|
22
|
+
assert_equal 999, redis.client.port
|
23
|
+
assert_equal 2, redis.client.db
|
24
|
+
assert_equal "secr3t", redis.client.password
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
27
|
+
def test_override_url_if_path_option_is_passed
|
28
|
+
redis = Redis.new :url => "redis://:secr3t@foo.com/foo:999/2", :path => "/tmp/redis.sock"
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
30
|
+
assert_equal "/tmp/redis.sock", redis.client.path
|
31
|
+
assert_equal nil, redis.client.host
|
32
|
+
assert_equal nil, redis.client.port
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
35
|
+
def test_overrides_url_if_another_connection_option_is_passed
|
36
|
+
redis = Redis.new :url => "redis://:secr3t@foo.com:999/2", :port => 1000
|
42
37
|
|
43
|
-
|
38
|
+
assert_equal "foo.com", redis.client.host
|
39
|
+
assert_equal 1000, redis.client.port
|
40
|
+
assert_equal 2, redis.client.db
|
41
|
+
assert_equal "secr3t", redis.client.password
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
44
|
+
def test_does_not_modify_the_passed_options
|
45
|
+
options = { :url => "redis://:secr3t@foo.com:999/2" }
|
46
|
+
|
47
|
+
Redis.new(options)
|
48
|
+
|
49
|
+
assert({ :url => "redis://:secr3t@foo.com:999/2" } == options)
|
50
|
+
end
|
47
51
|
|
48
|
-
|
49
|
-
|
52
|
+
def test_uses_redis_url_over_default_if_available
|
53
|
+
ENV["REDIS_URL"] = "redis://:secr3t@foo.com:999/2"
|
50
54
|
|
51
|
-
|
55
|
+
redis = Redis.new
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
assert_equal "foo.com", redis.client.host
|
58
|
+
assert_equal 999, redis.client.port
|
59
|
+
assert_equal 2, redis.client.db
|
60
|
+
assert_equal "secr3t", redis.client.password
|
57
61
|
|
58
|
-
|
62
|
+
ENV.delete("REDIS_URL")
|
63
|
+
end
|
59
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.rc2
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,11 +17,11 @@ authors:
|
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-05-15 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rake
|
24
|
-
requirement:
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
@@ -29,43 +29,15 @@ dependencies:
|
|
29
29
|
version: '0'
|
30
30
|
type: :development
|
31
31
|
prerelease: false
|
32
|
-
version_requirements:
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: cutest
|
35
|
-
requirement: &2152541580 !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
type: :development
|
42
|
-
prerelease: false
|
43
|
-
version_requirements: *2152541580
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: hiredis
|
46
|
-
requirement: &2152541000 !ruby/object:Gem::Requirement
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
33
|
none: false
|
48
34
|
requirements:
|
49
35
|
- - ! '>='
|
50
36
|
- !ruby/object:Gem::Version
|
51
37
|
version: '0'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: em-synchrony
|
57
|
-
requirement: &2152540580 !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: *2152540580
|
66
|
-
description: ! " A simple Ruby client trying to match Redis' API one-to-one while
|
67
|
-
still providing a Rubystic interface.\n It features thread safety, client-side
|
68
|
-
sharding, and an obsession for performance.\n"
|
38
|
+
description: ! " A Ruby client that tries to match Redis' API one-to-one, while
|
39
|
+
still\n providing an idiomatic interface. It features thread-safety,\n client-side
|
40
|
+
sharding, pipelining, and an obsession for performance.\n"
|
69
41
|
email:
|
70
42
|
- redis-db@googlegroups.com
|
71
43
|
executables: []
|
@@ -73,17 +45,17 @@ extensions: []
|
|
73
45
|
extra_rdoc_files: []
|
74
46
|
files:
|
75
47
|
- .gitignore
|
48
|
+
- .travis.yml
|
49
|
+
- .travis/Gemfile
|
76
50
|
- .yardopts
|
77
51
|
- CHANGELOG.md
|
78
52
|
- LICENSE
|
79
53
|
- README.md
|
80
54
|
- Rakefile
|
81
|
-
- TODO.md
|
82
55
|
- benchmarking/logging.rb
|
83
56
|
- benchmarking/pipeline.rb
|
84
57
|
- benchmarking/speed.rb
|
85
58
|
- benchmarking/suite.rb
|
86
|
-
- benchmarking/thread_safety.rb
|
87
59
|
- benchmarking/worker.rb
|
88
60
|
- examples/basic.rb
|
89
61
|
- examples/dist_redis.rb
|
@@ -108,6 +80,7 @@ files:
|
|
108
80
|
- lib/redis/subscribe.rb
|
109
81
|
- lib/redis/version.rb
|
110
82
|
- redis.gemspec
|
83
|
+
- test/blocking_commands_test.rb
|
111
84
|
- test/command_map_test.rb
|
112
85
|
- test/commands_on_hashes_test.rb
|
113
86
|
- test/commands_on_lists_test.rb
|
@@ -139,8 +112,8 @@ files:
|
|
139
112
|
- test/helper.rb
|
140
113
|
- test/helper_test.rb
|
141
114
|
- test/internals_test.rb
|
115
|
+
- test/lint/blocking_commands.rb
|
142
116
|
- test/lint/hashes.rb
|
143
|
-
- test/lint/internals.rb
|
144
117
|
- test/lint/lists.rb
|
145
118
|
- test/lint/sets.rb
|
146
119
|
- test/lint/sorted_sets.rb
|
@@ -149,16 +122,21 @@ files:
|
|
149
122
|
- test/persistence_control_commands_test.rb
|
150
123
|
- test/pipelining_commands_test.rb
|
151
124
|
- test/publish_subscribe_test.rb
|
152
|
-
- test/redis_mock.rb
|
153
125
|
- test/remote_server_control_commands_test.rb
|
154
126
|
- test/sorting_test.rb
|
127
|
+
- test/support/connection/hiredis.rb
|
128
|
+
- test/support/connection/ruby.rb
|
129
|
+
- test/support/connection/synchrony.rb
|
130
|
+
- test/support/redis_mock.rb
|
131
|
+
- test/support/wire/synchrony.rb
|
132
|
+
- test/support/wire/thread.rb
|
155
133
|
- test/synchrony_driver.rb
|
156
134
|
- test/test.conf
|
157
135
|
- test/thread_safety_test.rb
|
158
136
|
- test/transactions_test.rb
|
159
137
|
- test/unknown_commands_test.rb
|
160
138
|
- test/url_param_test.rb
|
161
|
-
homepage: https://github.com/
|
139
|
+
homepage: https://github.com/redis/redis-rb
|
162
140
|
licenses: []
|
163
141
|
post_install_message:
|
164
142
|
rdoc_options: []
|
@@ -178,11 +156,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
156
|
version: 1.3.1
|
179
157
|
requirements: []
|
180
158
|
rubyforge_project:
|
181
|
-
rubygems_version: 1.8.
|
159
|
+
rubygems_version: 1.8.24
|
182
160
|
signing_key:
|
183
161
|
specification_version: 3
|
184
162
|
summary: A Ruby client library for the Redis key-value store.
|
185
163
|
test_files:
|
164
|
+
- test/blocking_commands_test.rb
|
186
165
|
- test/command_map_test.rb
|
187
166
|
- test/commands_on_hashes_test.rb
|
188
167
|
- test/commands_on_lists_test.rb
|
@@ -214,8 +193,8 @@ test_files:
|
|
214
193
|
- test/helper.rb
|
215
194
|
- test/helper_test.rb
|
216
195
|
- test/internals_test.rb
|
196
|
+
- test/lint/blocking_commands.rb
|
217
197
|
- test/lint/hashes.rb
|
218
|
-
- test/lint/internals.rb
|
219
198
|
- test/lint/lists.rb
|
220
199
|
- test/lint/sets.rb
|
221
200
|
- test/lint/sorted_sets.rb
|
@@ -224,12 +203,18 @@ test_files:
|
|
224
203
|
- test/persistence_control_commands_test.rb
|
225
204
|
- test/pipelining_commands_test.rb
|
226
205
|
- test/publish_subscribe_test.rb
|
227
|
-
- test/redis_mock.rb
|
228
206
|
- test/remote_server_control_commands_test.rb
|
229
207
|
- test/sorting_test.rb
|
208
|
+
- test/support/connection/hiredis.rb
|
209
|
+
- test/support/connection/ruby.rb
|
210
|
+
- test/support/connection/synchrony.rb
|
211
|
+
- test/support/redis_mock.rb
|
212
|
+
- test/support/wire/synchrony.rb
|
213
|
+
- test/support/wire/thread.rb
|
230
214
|
- test/synchrony_driver.rb
|
231
215
|
- test/test.conf
|
232
216
|
- test/thread_safety_test.rb
|
233
217
|
- test/transactions_test.rb
|
234
218
|
- test/unknown_commands_test.rb
|
235
219
|
- test/url_param_test.rb
|
220
|
+
has_rdoc:
|
data/TODO.md
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Run with
|
2
|
-
#
|
3
|
-
# $ ruby -Ilib benchmarking/thread_safety.rb
|
4
|
-
#
|
5
|
-
|
6
|
-
begin
|
7
|
-
require "bench"
|
8
|
-
rescue LoadError
|
9
|
-
$stderr.puts "`gem install bench` and try again."
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
|
13
|
-
require "redis"
|
14
|
-
|
15
|
-
def stress(redis)
|
16
|
-
redis.flushdb
|
17
|
-
|
18
|
-
n = (ARGV.shift || 2000).to_i
|
19
|
-
|
20
|
-
n.times do |i|
|
21
|
-
key = "foo:#{i}"
|
22
|
-
redis.set key, i
|
23
|
-
redis.get key
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
thread_unsafe = Redis.new(:thread_safe => false)
|
28
|
-
thread_safe = Redis.new(:thread_safe => true)
|
29
|
-
|
30
|
-
benchmark "Thread-unsafe" do
|
31
|
-
stress(thread_unsafe)
|
32
|
-
end
|
33
|
-
|
34
|
-
benchmark "Thread-safe" do
|
35
|
-
stress(thread_safe)
|
36
|
-
end
|
37
|
-
|
38
|
-
run 10
|
data/test/lint/internals.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
test "Logger" do |r, log|
|
2
|
-
r.ping
|
3
|
-
|
4
|
-
assert log.string =~ /Redis >> PING/
|
5
|
-
assert log.string =~ /Redis >> \d+\.\d+ms/
|
6
|
-
end
|
7
|
-
|
8
|
-
test "Logger with pipelining" do |r, log|
|
9
|
-
r.pipelined do
|
10
|
-
r.set "foo", "bar"
|
11
|
-
r.get "foo"
|
12
|
-
end
|
13
|
-
|
14
|
-
assert log.string["SET foo bar"]
|
15
|
-
assert log.string["GET foo"]
|
16
|
-
end if $TEST_PIPELINING
|
17
|
-
|
18
|
-
test "Recovers from failed commands" do |r, _|
|
19
|
-
# See http://github.com/ezmobius/redis-rb/issues#issue/28
|
20
|
-
|
21
|
-
assert_raise do
|
22
|
-
r.command_that_doesnt_exist
|
23
|
-
end
|
24
|
-
|
25
|
-
assert_nothing_raised do
|
26
|
-
r.info
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
test "raises on protocol errors" do
|
31
|
-
redis_mock(:ping => lambda { |*_| "foo" }) do
|
32
|
-
assert_raise(Redis::ProtocolError) do
|
33
|
-
Redis.connect(:port => 6380).ping
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|