superfeedr-em-redis 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-redis/redis_protocol.rb +20 -41
- data/lib/em-redis/version.rb +1 -1
- metadata +2 -7
@@ -58,7 +58,7 @@ module EventMachine
|
|
58
58
|
"hgetall" => lambda{|r|
|
59
59
|
begin
|
60
60
|
Hash[*r]
|
61
|
-
rescue ArgumentError # Happens when the key is not set.
|
61
|
+
rescue ArgumentError # Happens when the key is not set, redis returns none.
|
62
62
|
{}
|
63
63
|
end
|
64
64
|
}
|
@@ -269,17 +269,16 @@ module EventMachine
|
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
272
|
-
def call_commands(pipeline, &blk)
|
272
|
+
def call_commands(pipeline, pipelined = true, &blk)
|
273
273
|
command = ""
|
274
|
-
|
274
|
+
comms = []
|
275
275
|
pipeline.each do |argv|
|
276
|
-
|
277
276
|
argv[0] = argv[0].to_s.downcase
|
278
277
|
|
279
278
|
argv[0] = ALIASES[argv[0]] if ALIASES[argv[0]]
|
280
279
|
raise "#{argv[0]} command is disabled" if DISABLED_COMMANDS[argv[0]]
|
281
280
|
|
282
|
-
|
281
|
+
comms.push(argv)
|
283
282
|
command << "*#{argv.size}\r\n"
|
284
283
|
argv.each do |a|
|
285
284
|
a = a.to_s
|
@@ -291,32 +290,13 @@ module EventMachine
|
|
291
290
|
|
292
291
|
@logger.debug { "*** sending: #{command}" } if @logger
|
293
292
|
maybe_lock do
|
294
|
-
@redis_callbacks << [
|
293
|
+
@redis_callbacks << [comms, pipelined, blk]
|
295
294
|
send_data command
|
296
295
|
end
|
297
296
|
end
|
298
297
|
|
299
298
|
def call_command(argv, &blk)
|
300
|
-
argv
|
301
|
-
|
302
|
-
argv[0] = argv[0].to_s.downcase
|
303
|
-
argv[0] = ALIASES[argv[0]] if ALIASES[argv[0]]
|
304
|
-
raise "#{argv[0]} command is disabled" if DISABLED_COMMANDS[argv[0]]
|
305
|
-
|
306
|
-
command = ""
|
307
|
-
command << "*#{argv.size}\r\n"
|
308
|
-
argv.each do |a|
|
309
|
-
a = a.to_s
|
310
|
-
command << "$#{get_size(a)}\r\n"
|
311
|
-
command << a
|
312
|
-
command << "\r\n"
|
313
|
-
end
|
314
|
-
|
315
|
-
@logger.debug { "*** sending: #{command}" } if @logger
|
316
|
-
maybe_lock do
|
317
|
-
@redis_callbacks << [REPLY_PROCESSOR[argv[0]], blk]
|
318
|
-
send_data command
|
319
|
-
end
|
299
|
+
call_commands([argv], false, &blk)
|
320
300
|
end
|
321
301
|
|
322
302
|
##
|
@@ -474,24 +454,23 @@ module EventMachine
|
|
474
454
|
end
|
475
455
|
|
476
456
|
callback = @redis_callbacks.shift
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
@values ||= []
|
488
|
-
@values << value
|
489
|
-
if pipeline_count > 1
|
490
|
-
@redis_callbacks.unshift [processors, pipeline_count - 1, blk] # Put back in the pipeline and just wait for the next
|
457
|
+
commands, pipelined, blk = callback
|
458
|
+
@values ||= []
|
459
|
+
command = commands[@values.size]
|
460
|
+
processor = REPLY_PROCESSOR[command[0]]
|
461
|
+
value = processor.call(value) if processor
|
462
|
+
@values.push(value)
|
463
|
+
if @values.size == commands.size
|
464
|
+
if !pipelined
|
465
|
+
# This was not a PIPELINE!
|
466
|
+
blk.call(@values[0]) if blk
|
491
467
|
else
|
492
468
|
blk.call(@values) if blk
|
493
|
-
@values = []
|
494
469
|
end
|
470
|
+
@values = []
|
471
|
+
else
|
472
|
+
# We need to wait for the other commands to succeed as well
|
473
|
+
@redis_callbacks.unshift([commands, blk])
|
495
474
|
end
|
496
475
|
end
|
497
476
|
|
data/lib/em-redis/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superfeedr-em-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 21
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Jonathan Broad
|
@@ -29,7 +28,6 @@ dependencies:
|
|
29
28
|
requirements:
|
30
29
|
- - ">="
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
hash: 3
|
33
31
|
segments:
|
34
32
|
- 0
|
35
33
|
version: "0"
|
@@ -43,7 +41,6 @@ dependencies:
|
|
43
41
|
requirements:
|
44
42
|
- - ~>
|
45
43
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 15424249
|
47
44
|
segments:
|
48
45
|
- 1
|
49
46
|
- 0
|
@@ -79,7 +76,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
76
|
requirements:
|
80
77
|
- - ">="
|
81
78
|
- !ruby/object:Gem::Version
|
82
|
-
hash: 3
|
83
79
|
segments:
|
84
80
|
- 0
|
85
81
|
version: "0"
|
@@ -88,7 +84,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
84
|
requirements:
|
89
85
|
- - ">="
|
90
86
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 3
|
92
87
|
segments:
|
93
88
|
- 0
|
94
89
|
version: "0"
|