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



519
520
521
522
523
# File 'lib/canvas_sync/job_batches/batch.rb', line 519

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



486
487
488
489
490
491
492
# File 'lib/canvas_sync/job_batches/batch.rb', line 486

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

#pipelined(*args, &block) ⇒ Object



494
495
496
497
498
499
500
# File 'lib/canvas_sync/job_batches/batch.rb', line 494

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

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

Returns:

  • (Boolean)


525
526
527
# File 'lib/canvas_sync/job_batches/batch.rb', line 525

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

#uget(key) ⇒ Object



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/canvas_sync/job_batches/batch.rb', line 502

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