redis 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +9 -8
- data/.travis.yml +10 -8
- data/CHANGELOG.md +4 -0
- data/Rakefile +21 -10
- data/lib/redis.rb +229 -72
- data/lib/redis/version.rb +1 -1
- data/test/blocking_commands_test.rb +1 -1
- data/test/command_map_test.rb +1 -1
- data/test/commands_on_hashes_test.rb +1 -1
- data/test/commands_on_lists_test.rb +1 -1
- data/test/commands_on_sets_test.rb +1 -1
- data/test/commands_on_sorted_sets_test.rb +1 -1
- data/test/commands_on_strings_test.rb +14 -14
- data/test/commands_on_value_types_test.rb +1 -1
- data/test/connection_handling_test.rb +1 -1
- data/test/distributed_blocking_commands_test.rb +1 -1
- data/test/distributed_commands_on_hashes_test.rb +1 -1
- data/test/distributed_commands_on_lists_test.rb +1 -1
- data/test/distributed_commands_on_sets_test.rb +1 -1
- data/test/distributed_commands_on_sorted_sets_test.rb +1 -1
- data/test/distributed_commands_on_strings_test.rb +7 -7
- data/test/distributed_commands_on_value_types_test.rb +1 -1
- data/test/distributed_commands_requiring_clustering_test.rb +14 -14
- data/test/distributed_connection_handling_test.rb +1 -1
- data/test/distributed_internals_test.rb +1 -1
- data/test/distributed_key_tags_test.rb +1 -1
- data/test/distributed_persistence_control_commands_test.rb +1 -1
- data/test/distributed_publish_subscribe_test.rb +1 -1
- data/test/distributed_remote_server_control_commands_test.rb +15 -15
- data/test/distributed_scripting_test.rb +57 -57
- data/test/distributed_sorting_test.rb +1 -1
- data/test/distributed_test.rb +1 -1
- data/test/distributed_transactions_test.rb +1 -1
- data/test/encoding_test.rb +1 -1
- data/test/error_replies_test.rb +1 -1
- data/test/helper.rb +10 -1
- data/test/helper_test.rb +1 -1
- data/test/internals_test.rb +20 -9
- data/test/lint/hashes.rb +17 -17
- data/test/lint/lists.rb +10 -10
- data/test/lint/sets.rb +14 -14
- data/test/lint/sorted_sets.rb +30 -30
- data/test/lint/strings.rb +45 -45
- data/test/lint/value_types.rb +32 -32
- data/test/persistence_control_commands_test.rb +1 -1
- data/test/pipelining_commands_test.rb +1 -1
- data/test/publish_subscribe_test.rb +1 -1
- data/test/remote_server_control_commands_test.rb +7 -7
- data/test/scanning_test.rb +413 -0
- data/test/scripting_test.rb +45 -45
- data/test/sorting_test.rb +1 -1
- data/test/thread_safety_test.rb +1 -1
- data/test/transactions_test.rb +1 -1
- data/test/unknown_commands_test.rb +1 -1
- data/test/url_param_test.rb +1 -1
- metadata +6 -4
- data/test/db/.gitignore +0 -1
data/lib/redis/version.rb
CHANGED
data/test/command_map_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
require "lint/strings"
|
5
5
|
|
6
6
|
class TestCommandsOnStrings < Test::Unit::TestCase
|
@@ -82,18 +82,18 @@ class TestCommandsOnStrings < Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_bitop
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
85
|
+
target_version "2.5.10" do
|
86
|
+
r.set("foo", "a")
|
87
|
+
r.set("bar", "b")
|
88
|
+
|
89
|
+
r.bitop(:and, "foo&bar", "foo", "bar")
|
90
|
+
assert_equal "\x60", r.get("foo&bar")
|
91
|
+
r.bitop(:or, "foo|bar", "foo", "bar")
|
92
|
+
assert_equal "\x63", r.get("foo|bar")
|
93
|
+
r.bitop(:xor, "foo^bar", "foo", "bar")
|
94
|
+
assert_equal "\x03", r.get("foo^bar")
|
95
|
+
r.bitop(:not, "~foo", "foo")
|
96
|
+
assert_equal "\x9E", r.get("~foo")
|
97
|
+
end
|
98
98
|
end
|
99
99
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
require "lint/strings"
|
5
5
|
|
6
6
|
class TestDistributedCommandsOnStrings < Test::Unit::TestCase
|
@@ -47,13 +47,13 @@ class TestDistributedCommandsOnStrings < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_bitop
|
50
|
-
|
50
|
+
target_version "2.5.10" do
|
51
|
+
assert_raise Redis::Distributed::CannotDistribute do
|
52
|
+
r.set("foo", "a")
|
53
|
+
r.set("bar", "b")
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
r.set("bar", "b")
|
55
|
-
|
56
|
-
r.bitop(:and, "foo&bar", "foo", "bar")
|
55
|
+
r.bitop(:and, "foo&bar", "foo", "bar")
|
56
|
+
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class TestDistributedCommandsRequiringClustering < Test::Unit::TestCase
|
6
6
|
|
@@ -147,18 +147,18 @@ class TestDistributedCommandsRequiringClustering < Test::Unit::TestCase
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def test_bitop
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
150
|
+
target_version "2.5.10" do
|
151
|
+
r.set("{qux}foo", "a")
|
152
|
+
r.set("{qux}bar", "b")
|
153
|
+
|
154
|
+
r.bitop(:and, "{qux}foo&bar", "{qux}foo", "{qux}bar")
|
155
|
+
assert_equal "\x60", r.get("{qux}foo&bar")
|
156
|
+
r.bitop(:or, "{qux}foo|bar", "{qux}foo", "{qux}bar")
|
157
|
+
assert_equal "\x63", r.get("{qux}foo|bar")
|
158
|
+
r.bitop(:xor, "{qux}foo^bar", "{qux}foo", "{qux}bar")
|
159
|
+
assert_equal "\x03", r.get("{qux}foo^bar")
|
160
|
+
r.bitop(:not, "{qux}~foo", "{qux}foo")
|
161
|
+
assert_equal "\x9E", r.get("{qux}~foo")
|
162
|
+
end
|
163
163
|
end
|
164
164
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase
|
6
6
|
|
@@ -28,13 +28,13 @@ class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_info_commandstats
|
31
|
-
|
31
|
+
target_version "2.5.7" do
|
32
|
+
r.nodes.each { |n| n.config(:resetstat) }
|
33
|
+
r.ping # Executed on every node
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
r.info(:commandstats).each do |info|
|
37
|
-
assert_equal "1", info["ping"]["calls"]
|
35
|
+
r.info(:commandstats).each do |info|
|
36
|
+
assert_equal "1", info["ping"]["calls"]
|
37
|
+
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -52,15 +52,15 @@ class TestDistributedRemoteServerControlCommands < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_time
|
55
|
-
|
55
|
+
target_version "2.5.4" do
|
56
|
+
# Test that the difference between the time that Ruby reports and the time
|
57
|
+
# that Redis reports is minimal (prevents the test from being racy).
|
58
|
+
r.time.each do |rv|
|
59
|
+
redis_usec = rv[0] * 1_000_000 + rv[1]
|
60
|
+
ruby_usec = Integer(Time.now.to_f * 1_000_000)
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
r.time.each do |rv|
|
60
|
-
redis_usec = rv[0] * 1_000_000 + rv[1]
|
61
|
-
ruby_usec = Integer(Time.now.to_f * 1_000_000)
|
62
|
-
|
63
|
-
assert 500_000 > (ruby_usec - redis_usec).abs
|
62
|
+
assert 500_000 > (ruby_usec - redis_usec).abs
|
63
|
+
end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require "helper"
|
3
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
class TestDistributedScripting < Test::Unit::TestCase
|
6
6
|
|
@@ -11,92 +11,92 @@ class TestDistributedScripting < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_script_exists
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
target_version "2.5.9" do # 2.6-rc1
|
15
|
+
a = to_sha("return 1")
|
16
|
+
b = a.succ
|
17
|
+
|
18
|
+
assert_equal [true], r.script(:exists, a)
|
19
|
+
assert_equal [false], r.script(:exists, b)
|
20
|
+
assert_equal [[true]], r.script(:exists, [a])
|
21
|
+
assert_equal [[false]], r.script(:exists, [b])
|
22
|
+
assert_equal [[true, false]], r.script(:exists, [a, b])
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_script_flush
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
target_version "2.5.9" do # 2.6-rc1
|
28
|
+
sha = to_sha("return 1")
|
29
|
+
assert r.script(:exists, sha).first
|
30
|
+
assert_equal ["OK"], r.script(:flush)
|
31
|
+
assert !r.script(:exists, sha).first
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_script_kill
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
target_version "2.5.9" do # 2.6-rc1
|
37
|
+
redis_mock(:script => lambda { |arg| "+#{arg.upcase}" }) do |redis|
|
38
|
+
assert_equal ["KILL"], redis.script(:kill)
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_eval
|
44
|
-
|
44
|
+
target_version "2.5.9" do # 2.6-rc1
|
45
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
46
|
+
r.eval("return #KEYS")
|
47
|
+
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
50
|
+
r.eval("return KEYS", ["k1", "k2"])
|
51
|
+
end
|
49
52
|
|
50
|
-
|
51
|
-
r.eval("return
|
53
|
+
assert_equal ["k1"], r.eval("return KEYS", ["k1"])
|
54
|
+
assert_equal ["a1", "a2"], r.eval("return ARGV", ["k1"], ["a1", "a2"])
|
52
55
|
end
|
53
|
-
|
54
|
-
assert_equal ["k1"], r.eval("return KEYS", ["k1"])
|
55
|
-
assert_equal ["a1", "a2"], r.eval("return ARGV", ["k1"], ["a1", "a2"])
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_eval_with_options_hash
|
59
|
-
|
59
|
+
target_version "2.5.9" do # 2.6-rc1
|
60
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
61
|
+
r.eval("return #KEYS", {})
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
65
|
+
r.eval("return KEYS", { :keys => ["k1", "k2"] })
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
r.eval("return
|
68
|
+
assert_equal ["k1"], r.eval("return KEYS", { :keys => ["k1"] })
|
69
|
+
assert_equal ["a1", "a2"], r.eval("return ARGV", { :keys => ["k1"], :argv => ["a1", "a2"] })
|
67
70
|
end
|
68
|
-
|
69
|
-
assert_equal ["k1"], r.eval("return KEYS", { :keys => ["k1"] })
|
70
|
-
assert_equal ["a1", "a2"], r.eval("return ARGV", { :keys => ["k1"], :argv => ["a1", "a2"] })
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_evalsha
|
74
|
-
|
74
|
+
target_version "2.5.9" do # 2.6-rc1
|
75
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
76
|
+
r.evalsha(to_sha("return #KEYS"))
|
77
|
+
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
80
|
+
r.evalsha(to_sha("return KEYS"), ["k1", "k2"])
|
81
|
+
end
|
79
82
|
|
80
|
-
|
81
|
-
r.evalsha(to_sha("return
|
83
|
+
assert_equal ["k1"], r.evalsha(to_sha("return KEYS"), ["k1"])
|
84
|
+
assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), ["k1"], ["a1", "a2"])
|
82
85
|
end
|
83
|
-
|
84
|
-
assert_equal ["k1"], r.evalsha(to_sha("return KEYS"), ["k1"])
|
85
|
-
assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), ["k1"], ["a1", "a2"])
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_evalsha_with_options_hash
|
89
|
-
|
89
|
+
target_version "2.5.9" do # 2.6-rc1
|
90
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
91
|
+
r.evalsha(to_sha("return #KEYS"), {})
|
92
|
+
end
|
90
93
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
+
assert_raises(Redis::Distributed::CannotDistribute) do
|
95
|
+
r.evalsha(to_sha("return KEYS"), { :keys => ["k1", "k2"] })
|
96
|
+
end
|
94
97
|
|
95
|
-
|
96
|
-
r.evalsha(to_sha("return
|
98
|
+
assert_equal ["k1"], r.evalsha(to_sha("return KEYS"), { :keys => ["k1"] })
|
99
|
+
assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), { :keys => ["k1"], :argv => ["a1", "a2"] })
|
97
100
|
end
|
98
|
-
|
99
|
-
assert_equal ["k1"], r.evalsha(to_sha("return KEYS"), { :keys => ["k1"] })
|
100
|
-
assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), { :keys => ["k1"], :argv => ["a1", "a2"] })
|
101
101
|
end
|
102
102
|
end
|