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



578
579
580
581
582
# File 'lib/canvas_sync/job_batches/batch.rb', line 578

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



545
546
547
548
549
550
551
# File 'lib/canvas_sync/job_batches/batch.rb', line 545

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

#pipelined(*args, &block) ⇒ Object



553
554
555
556
557
558
559
# File 'lib/canvas_sync/job_batches/batch.rb', line 553

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)


584
585
586
# File 'lib/canvas_sync/job_batches/batch.rb', line 584

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

#uget(key) ⇒ Object



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/canvas_sync/job_batches/batch.rb', line 561

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