redis_pipeline 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/redis_pipeline/redis_pipeline.rb +1 -1
- data/lib/redis_pipeline/version.rb +1 -1
- data/redis_pipeline.gemspec +2 -2
- data/test/test_redis_pipeline.rb +11 -11
- metadata +11 -24
data/README.md
CHANGED
@@ -38,13 +38,13 @@ Create a new pipeline
|
|
38
38
|
Queue up commands with add_commands either as a single string
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
pipeline.add_commands('set
|
41
|
+
pipeline.add_commands('set|hello|world')
|
42
42
|
```
|
43
43
|
|
44
44
|
or an array
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
array = ['hset
|
47
|
+
array = ['hset|gem|first_name|redis', '|hset|gem|last_name|pipeline']
|
48
48
|
pipeline.add_commands(array)
|
49
49
|
```
|
50
50
|
|
data/redis_pipeline.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
require File.expand_path('../lib/redis_pipeline/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Davin Lagerroos"]
|
6
|
-
gem.email = ["dlagerroos@ssa-i.org"]
|
5
|
+
gem.authors = ["Ian Whitney", "Davin Lagerroos"]
|
6
|
+
gem.email = ["iwhitney@ssa-i.org", "dlagerroos@ssa-i.org"]
|
7
7
|
gem.description = %q{Send commands to a redis server in pipelined batches}
|
8
8
|
gem.summary = %q{Establishes a connection to a redis server. You can then pass it commands that will be queued to be pipelined. Intended for mass upload.}
|
9
9
|
gem.homepage = ""
|
data/test/test_redis_pipeline.rb
CHANGED
@@ -22,21 +22,21 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_add_commands_adds_array_of_commands_as_seperate_commands
|
25
|
-
commands = ["hset
|
25
|
+
commands = ["hset|person:0|first_name|joe", "hest|person:0|last_name|smith"]
|
26
26
|
@pipeline.add_commands(commands)
|
27
27
|
assert_equal commands.length, @pipeline.send(:commands).length
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_add_commands_adds_string_as_single_command
|
31
|
-
commands = "hset
|
31
|
+
commands = "hset|person:0 first_name joe"
|
32
32
|
@pipeline.add_commands(commands)
|
33
33
|
assert_equal 1, @pipeline.send(:commands).length
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_add_commands_queues_commands_at_end
|
37
|
-
commands = ["hset
|
37
|
+
commands = ["hset|person:0|first_name|joe", "hest|person:0|last_name|smith"]
|
38
38
|
@pipeline.add_commands(commands)
|
39
|
-
last_command = "hset
|
39
|
+
last_command = "hset|person:1|first_name|jane"
|
40
40
|
@pipeline.add_commands(last_command)
|
41
41
|
assert_equal commands[0], @pipeline.send(:commands).first
|
42
42
|
assert_equal last_command, @pipeline.send(:commands).last
|
@@ -63,8 +63,8 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
63
63
|
redis = Redis.new(:host => uri_parsed.host, :port => uri_parsed.port, :password => uri_parsed.password)
|
64
64
|
@pipeline.add_commands(three_batches_of_commands)
|
65
65
|
|
66
|
-
first_command = @pipeline.send(:commands).first.split("
|
67
|
-
last_command = @pipeline.send(:commands).last.split("
|
66
|
+
first_command = @pipeline.send(:commands).first.split("|")
|
67
|
+
last_command = @pipeline.send(:commands).last.split("|")
|
68
68
|
assert_equal Hash.new(), redis.send("hgetall", first_command[1])
|
69
69
|
assert_equal Hash.new(), redis.send("hgetall", last_command[1])
|
70
70
|
|
@@ -85,13 +85,13 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_execute_commands_returns_false_if_error
|
88
|
-
mismatched_commands = ['set
|
88
|
+
mismatched_commands = ['set|"string_key"|"string_value"', 'hget|"string_key"|"string_not_a_hash"']
|
89
89
|
@pipeline.add_commands(mismatched_commands)
|
90
90
|
assert_equal false, @pipeline.execute_commands
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_execute_commands_populates_errors_if_error
|
94
|
-
mismatched_commands = ['set
|
94
|
+
mismatched_commands = ['set|"string_key"|"string_value"', 'hget|"string_key"|"string_not_a_hash"']
|
95
95
|
@pipeline.add_commands(mismatched_commands)
|
96
96
|
@pipeline.execute_commands
|
97
97
|
assert_equal 1, @pipeline.errors.count, "#{@pipeline.errors.inspect}"
|
@@ -101,7 +101,7 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
101
101
|
private
|
102
102
|
|
103
103
|
def three_batches_of_commands
|
104
|
-
first_names = ["Lindsey", "Dodie", "Tommie", "Aletha", "Matilda", "Robby", "Forest", "Sherrie", "Elroy", "Darlene", "Blossom", "Preston", "Ivan", "Denisha", "Antonietta", "Lenora", "Fatimah", "Alvaro", "Madeleine", "Johnsie", "Jacki"]
|
104
|
+
first_names = ["Lindsey Sue", "Dodie", "Tommie", "Aletha", "Matilda", "Robby", "Forest", "Sherrie", "Elroy", "Darlene", "Blossom", "Preston", "Ivan", "Denisha", "Antonietta", "Lenora", "Fatimah", "Alvaro", "Madeleine", "Johnsie", "Jacki"]
|
105
105
|
last_names = ["Austino", "Egnor", "Mclauglin", "Vettel", "Osornio", "Kloke", "Neall", "Licon", "Bergren", "Guialdo", "Heu", "Lilla", "Fogt", "Ellinghuysen", "Banner", "Gammage", "Fleniken", "Byerley", "Mccandless", "Hatchet", "Segal", "Bagnall", "Mangum", "Marinella", "Hunke", "Klis", "Skonczewski", "Aiava", "Masson", "Hochhauser", "Pfost", "Cripps", "Surrell", "Carstens", "Moeder", "Feller", "Turri", "Plummer", "Liuzza", "Macaskill", "Pirie", "Haase", "Gummersheimer", "Caden", "Balich", "Franssen", "Barbur", "Bonker", "Millar", "Armijo", "Canales", "Kucera", "Ahlstrom", "Marcoux", "Dagel", "Vandonsel", "Lagrasse", "Bolten", "Smyer", "Spiker", "Detz", "Munar", "Oieda", "Westin", "Levenson", "Ramagos", "Lipson", "Crankshaw", "Polton", "Seibt", "Genrich", "Shempert", "Bonillas", "Stout", "Caselli", "Jaji", "Kudo", "Feauto", "Hetland", "Hsieh", "Iwasko", "Jayme", "Lebby", "Dircks", "Hainley", "Gielstra", "Dozois", "Suss", "Matern", "Mcloud", "Fassio", "Blumstein", "Qin", "Gindi", "Petrizzo", "Beath", "Tonneson", "Fraga", "Tamura", "Cappellano", "Galella"]
|
106
106
|
|
107
107
|
# each first_name,last_name pair is 2 commands so to get 2 batches plus extra we only need batch_size number pairs plus some extra * 1.33
|
@@ -110,8 +110,8 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
110
110
|
(0..number_of_commands).each do |i|
|
111
111
|
first = first_names.shift
|
112
112
|
last = last_names.shift
|
113
|
-
commands << "hset
|
114
|
-
commands << "hset
|
113
|
+
commands << "hset|person:#{i}|first_name|#{first}"
|
114
|
+
commands << "hset|person:#{i}|lsst_name|#{last}"
|
115
115
|
first_names.push(first)
|
116
116
|
last_names.push(last)
|
117
117
|
end
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
+
- Ian Whitney
|
8
9
|
- Davin Lagerroos
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-31 00:00:00.000000000Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: gem_configurator
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &2161477740 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,15 +22,10 @@ dependencies:
|
|
21
22
|
version: '0'
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
25
|
+
version_requirements: *2161477740
|
30
26
|
- !ruby/object:Gem::Dependency
|
31
27
|
name: redis
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirement: &2161477320 !ruby/object:Gem::Requirement
|
33
29
|
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
@@ -37,15 +33,10 @@ dependencies:
|
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
36
|
+
version_requirements: *2161477320
|
46
37
|
- !ruby/object:Gem::Dependency
|
47
38
|
name: rake
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirement: &2161476900 !ruby/object:Gem::Requirement
|
49
40
|
none: false
|
50
41
|
requirements:
|
51
42
|
- - ! '>='
|
@@ -53,14 +44,10 @@ dependencies:
|
|
53
44
|
version: '0'
|
54
45
|
type: :development
|
55
46
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
47
|
+
version_requirements: *2161476900
|
62
48
|
description: Send commands to a redis server in pipelined batches
|
63
49
|
email:
|
50
|
+
- iwhitney@ssa-i.org
|
64
51
|
- dlagerroos@ssa-i.org
|
65
52
|
executables: []
|
66
53
|
extensions: []
|
@@ -100,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
87
|
version: '0'
|
101
88
|
requirements: []
|
102
89
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.16
|
104
91
|
signing_key:
|
105
92
|
specification_version: 3
|
106
93
|
summary: Establishes a connection to a redis server. You can then pass it commands
|