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.
Files changed (77) hide show
  1. data/.travis.yml +50 -0
  2. data/.travis/Gemfile +11 -0
  3. data/CHANGELOG.md +47 -19
  4. data/README.md +160 -149
  5. data/Rakefile +15 -50
  6. data/examples/pubsub.rb +1 -1
  7. data/examples/unicorn/config.ru +1 -1
  8. data/examples/unicorn/unicorn.rb +1 -1
  9. data/lib/redis.rb +790 -390
  10. data/lib/redis/client.rb +137 -49
  11. data/lib/redis/connection/hiredis.rb +26 -15
  12. data/lib/redis/connection/ruby.rb +170 -53
  13. data/lib/redis/connection/synchrony.rb +23 -35
  14. data/lib/redis/distributed.rb +92 -32
  15. data/lib/redis/errors.rb +4 -2
  16. data/lib/redis/pipeline.rb +17 -6
  17. data/lib/redis/version.rb +1 -1
  18. data/redis.gemspec +4 -6
  19. data/test/blocking_commands_test.rb +42 -0
  20. data/test/command_map_test.rb +18 -17
  21. data/test/commands_on_hashes_test.rb +13 -12
  22. data/test/commands_on_lists_test.rb +35 -45
  23. data/test/commands_on_sets_test.rb +55 -54
  24. data/test/commands_on_sorted_sets_test.rb +106 -105
  25. data/test/commands_on_strings_test.rb +64 -55
  26. data/test/commands_on_value_types_test.rb +66 -54
  27. data/test/connection_handling_test.rb +136 -151
  28. data/test/distributed_blocking_commands_test.rb +33 -40
  29. data/test/distributed_commands_on_hashes_test.rb +6 -7
  30. data/test/distributed_commands_on_lists_test.rb +13 -14
  31. data/test/distributed_commands_on_sets_test.rb +57 -58
  32. data/test/distributed_commands_on_sorted_sets_test.rb +11 -12
  33. data/test/distributed_commands_on_strings_test.rb +31 -32
  34. data/test/distributed_commands_on_value_types_test.rb +61 -46
  35. data/test/distributed_commands_requiring_clustering_test.rb +108 -108
  36. data/test/distributed_connection_handling_test.rb +14 -15
  37. data/test/distributed_internals_test.rb +7 -19
  38. data/test/distributed_key_tags_test.rb +36 -36
  39. data/test/distributed_persistence_control_commands_test.rb +17 -14
  40. data/test/distributed_publish_subscribe_test.rb +61 -69
  41. data/test/distributed_remote_server_control_commands_test.rb +39 -28
  42. data/test/distributed_sorting_test.rb +12 -13
  43. data/test/distributed_test.rb +40 -41
  44. data/test/distributed_transactions_test.rb +20 -21
  45. data/test/encoding_test.rb +12 -9
  46. data/test/error_replies_test.rb +42 -36
  47. data/test/helper.rb +118 -85
  48. data/test/helper_test.rb +20 -6
  49. data/test/internals_test.rb +167 -103
  50. data/test/lint/blocking_commands.rb +124 -0
  51. data/test/lint/hashes.rb +115 -93
  52. data/test/lint/lists.rb +86 -80
  53. data/test/lint/sets.rb +68 -62
  54. data/test/lint/sorted_sets.rb +200 -195
  55. data/test/lint/strings.rb +112 -94
  56. data/test/lint/value_types.rb +76 -55
  57. data/test/persistence_control_commands_test.rb +17 -12
  58. data/test/pipelining_commands_test.rb +135 -126
  59. data/test/publish_subscribe_test.rb +105 -110
  60. data/test/remote_server_control_commands_test.rb +74 -58
  61. data/test/sorting_test.rb +31 -29
  62. data/test/support/connection/hiredis.rb +1 -0
  63. data/test/support/connection/ruby.rb +1 -0
  64. data/test/support/connection/synchrony.rb +17 -0
  65. data/test/{redis_mock.rb → support/redis_mock.rb} +24 -21
  66. data/test/support/wire/synchrony.rb +24 -0
  67. data/test/support/wire/thread.rb +5 -0
  68. data/test/synchrony_driver.rb +9 -9
  69. data/test/test.conf +1 -1
  70. data/test/thread_safety_test.rb +21 -19
  71. data/test/transactions_test.rb +189 -118
  72. data/test/unknown_commands_test.rb +9 -8
  73. data/test/url_param_test.rb +46 -41
  74. metadata +28 -43
  75. data/TODO.md +0 -4
  76. data/benchmarking/thread_safety.rb +0 -38
  77. data/test/lint/internals.rb +0 -36
@@ -1,13 +1,14 @@
1
- # encoding: UTF-8
1
+ # encoding: UTF-8
2
2
 
3
- require File.expand_path("./helper", File.dirname(__FILE__))
3
+ require "helper"
4
4
 
5
- setup do
6
- init Redis.new(OPTIONS)
7
- end
5
+ class TestUnknownCommands < Test::Unit::TestCase
6
+
7
+ include Helper::Client
8
8
 
9
- test "should try to work" do |r|
10
- assert_raise Redis::CommandError do
11
- r.not_yet_implemented_command
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
@@ -1,59 +1,64 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path("./helper", File.dirname(__FILE__))
3
+ require "helper"
4
4
 
5
- test "URL defaults to 127.0.0.1:6379" do
6
- redis = Redis.connect
5
+ class TestUrlParam < Test::Unit::TestCase
7
6
 
8
- assert "127.0.0.1" == redis.client.host
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
- test "allows to pass in a URL" do
15
- redis = Redis.connect :url => "redis://:secr3t@foo.com:999/2"
9
+ def test_url_defaults_to_______________
10
+ redis = Redis.new
16
11
 
17
- assert "foo.com" == redis.client.host
18
- assert 999 == redis.client.port
19
- assert 2 == redis.client.db
20
- assert "secr3t" == redis.client.password
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
- test "override URL if path option is passed" do
24
- redis = Redis.connect :url => "redis://:secr3t@foo.com/foo:999/2", :path => "/tmp/redis.sock"
18
+ def test_allows_to_pass_in_a_url
19
+ redis = Redis.new :url => "redis://:secr3t@foo.com:999/2"
25
20
 
26
- assert "/tmp/redis.sock" == redis.client.path
27
- assert nil == redis.client.host
28
- assert nil == redis.client.port
29
- end
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
- test "overrides URL if another connection option is passed" do
32
- redis = Redis.connect :url => "redis://:secr3t@foo.com:999/2", :port => 1000
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
- assert "foo.com" == redis.client.host
35
- assert 1000 == redis.client.port
36
- assert 2 == redis.client.db
37
- assert "secr3t" == redis.client.password
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
- test "does not modify the passed options" do
41
- options = { :url => "redis://:secr3t@foo.com:999/2" }
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
- redis = Redis.connect(options)
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
- assert({ :url => "redis://:secr3t@foo.com:999/2" } == options)
46
- end
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
- test "uses REDIS_URL over default if available" do
49
- ENV["REDIS_URL"] = "redis://:secr3t@foo.com:999/2"
52
+ def test_uses_redis_url_over_default_if_available
53
+ ENV["REDIS_URL"] = "redis://:secr3t@foo.com:999/2"
50
54
 
51
- redis = Redis.connect
55
+ redis = Redis.new
52
56
 
53
- assert "foo.com" == redis.client.host
54
- assert 999 == redis.client.port
55
- assert 2 == redis.client.db
56
- assert "secr3t" == redis.client.password
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
- ENV.delete("REDIS_URL")
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.rc1
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-03-10 00:00:00.000000000 Z
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: &2152542300 !ruby/object:Gem::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: *2152542300
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
- type: :development
53
- prerelease: false
54
- version_requirements: *2152541000
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/ezmobius/redis-rb
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.10
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,4 +0,0 @@
1
- # 2.3
2
-
3
- * Remove the splat from the prototypes of `Client#call`, `Client#call_loop`,
4
- `Pipeline#call` and `Subscription#call`.
@@ -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
@@ -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