superfeedr-em-redis 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -261,6 +261,33 @@ module EventMachine
261
261
  callback { yield }
262
262
  end
263
263
  end
264
+
265
+ def call_commands(pipeline, &blk)
266
+ command = ""
267
+ processors = []
268
+ pipeline.each do |argv|
269
+
270
+ argv[0] = argv[0].to_s.downcase
271
+
272
+ argv[0] = ALIASES[argv[0]] if ALIASES[argv[0]]
273
+ raise "#{argv[0]} command is disabled" if DISABLED_COMMANDS[argv[0]]
274
+
275
+ processors.push(REPLY_PROCESSOR[argv[0]])
276
+ command << "*#{argv.size}\r\n"
277
+ argv.each do |a|
278
+ a = a.to_s
279
+ command << "$#{get_size(a)}\r\n"
280
+ command << a
281
+ command << "\r\n"
282
+ end
283
+ end
284
+
285
+ @logger.debug { "*** sending: #{command}" } if @logger
286
+ maybe_lock do
287
+ @redis_callbacks << [processors, processors.size, blk]
288
+ send_data command
289
+ end
290
+ end
264
291
 
265
292
  def call_command(argv, &blk)
266
293
  argv = argv.dup
@@ -443,13 +470,17 @@ module EventMachine
443
470
  if callback.length == 2
444
471
  processor, blk = callback
445
472
  value = processor.call(value) if processor
473
+
446
474
  blk.call(value) if blk
447
475
  else
448
- processor, pipeline_count, blk = callback
449
- value = processor.call(value) if processor
476
+ # That was a pipeline!
477
+ processors, pipeline_count, blk = callback
478
+ p = processors.shift()
479
+ value = p.call(value) if p
480
+ @values ||= []
450
481
  @values << value
451
482
  if pipeline_count > 1
452
- @redis_callbacks.unshift [processor, pipeline_count - 1, blk]
483
+ @redis_callbacks.unshift [processors, pipeline_count - 1, blk] # Put back in the pipeline and just wait for the next
453
484
  else
454
485
  blk.call(@values) if blk
455
486
  @values = []
@@ -1,3 +1,3 @@
1
1
  module EMRedis
2
- VERSION = '0.3.0' unless defined? ::EMRedis::VERSION
2
+ VERSION = '0.3.1' unless defined? ::EMRedis::VERSION
3
3
  end
metadata CHANGED
@@ -5,18 +5,19 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Broad
13
13
  - Eugene Pimenov
14
+ - Stephan Maka
14
15
  - Julien Genestoux
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2011-02-20 00:00:00 -05:00
20
+ date: 2011-02-23 00:00:00 -05:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency