Class: CanvasSync::JobBatches::Batch::RedisProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas_sync/job_batches/batch.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



472
473
474
475
476
# File 'lib/canvas_sync/job_batches/batch.rb', line 472

def method_missing(method_name, *arguments, &block)
  Batch.redis do |r|
    r.send(method_name, *arguments, &block)
  end
end

Instance Method Details

#multi(*args, &block) ⇒ Object



435
436
437
438
439
440
441
# File 'lib/canvas_sync/job_batches/batch.rb', line 435

def multi(*args, &block)
  Batch.redis do |r|
    r.multi(*args) do |r|
      block.call(r)
    end
  end
end

#pipelined(*args, &block) ⇒ Object



443
444
445
446
447
448
449
450
451
452
453
# File 'lib/canvas_sync/job_batches/batch.rb', line 443

def pipelined(*args, &block)
  Batch.redis do |r|
    if block.arity == 1
      r.pipelined(*args) do
        block.call(r)
      end
    else
      r.pipelined(*args, &block)
    end
  end
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


478
479
480
# File 'lib/canvas_sync/job_batches/batch.rb', line 478

def respond_to_missing?(method_name, include_private = false)
  super || Redis.method_defined?(method_name)
end

#uget(key) ⇒ Object



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/canvas_sync/job_batches/batch.rb', line 455

def uget(key)
  Batch.redis do |r|
    case r.type(key)
    when 'string'
      r.get(key)
    when 'list'
      r.lrange(key, 0, -1)
    when 'hash'
      r.hgetall(key)
    when 'set'
      r.smembers(key)
    when 'zset'
      r.zrange(key, 0, -1)
    end
  end
end