redis_pipeline 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -49,18 +49,18 @@ module RedisPipeline
|
|
49
49
|
|
50
50
|
def command_batch
|
51
51
|
command_batch = []
|
52
|
-
commands.first(@settings[
|
52
|
+
commands.first(@settings['batch_size']).count.times do
|
53
53
|
command_batch << commands.shift
|
54
54
|
end
|
55
55
|
command_batch
|
56
56
|
end
|
57
57
|
|
58
58
|
def default_settings
|
59
|
-
{
|
59
|
+
{'uri' => 'redis://localhost:6379', 'batch_size' => 1000}
|
60
60
|
end
|
61
61
|
|
62
62
|
def open_redis_connection
|
63
|
-
uri = URI.parse(settings[
|
63
|
+
uri = URI.parse(@settings['uri'])
|
64
64
|
Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
|
65
65
|
end
|
66
66
|
|
data/redis_pipeline.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "redis_pipeline"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = RedisPipeline::VERSION
|
17
|
-
gem.add_dependency('gem_configurator', '~> 1.
|
17
|
+
gem.add_dependency('gem_configurator', '~> 1.2')
|
18
18
|
gem.add_dependency 'redis'
|
19
19
|
gem.add_development_dependency 'rake'
|
20
20
|
end
|
data/test/test_redis_pipeline.rb
CHANGED
@@ -4,7 +4,7 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@pipeline = RedisPipeline::RedisPipeline.new
|
7
|
-
@uri = @pipeline.settings[
|
7
|
+
@uri = @pipeline.settings['uri']
|
8
8
|
end
|
9
9
|
|
10
10
|
def teardown
|
@@ -59,7 +59,7 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
59
59
|
@pipeline.add_command(full_command_set)
|
60
60
|
single_batch = @pipeline.send(:command_batch)
|
61
61
|
|
62
|
-
upper_limit = (@pipeline.settings[
|
62
|
+
upper_limit = (@pipeline.settings['batch_size'] - 1)
|
63
63
|
assert_equal full_command_set[0..upper_limit], single_batch
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,7 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
67
67
|
@pipeline.add_command(three_batches_of_commands)
|
68
68
|
count = @pipeline.send(:commands).length
|
69
69
|
@pipeline.send(:command_batch)
|
70
|
-
assert_equal (count - @pipeline.settings[
|
70
|
+
assert_equal (count - @pipeline.settings['batch_size']), @pipeline.send(:commands).length
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_execute_sends_commands_to_redis
|
@@ -117,7 +117,7 @@ class TestRedisPipeline < Test::Unit::TestCase
|
|
117
117
|
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"]
|
118
118
|
|
119
119
|
# 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
|
120
|
-
number_of_commands = (@pipeline.settings[
|
120
|
+
number_of_commands = (@pipeline.settings['batch_size'] * 1.33)
|
121
121
|
commands = []
|
122
122
|
(0..number_of_commands).each do |i|
|
123
123
|
first = first_names.shift
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-06 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gem_configurator
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153336240 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '1.
|
22
|
+
version: '1.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153336240
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: redis
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153335820 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153335820
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rake
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153335360 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153335360
|
48
48
|
description: Send commands to a redis server in pipelined batches
|
49
49
|
email:
|
50
50
|
- iwhitney@ssa-i.org
|