module EventMachine::Protocols::Redis
Constants
- SYNC
Attributes
connected[R]
Public Class Methods
connect(*args)
click to toggle source
# File lib/em-synchrony/em-redis.rb, line 16 def self.connect(*args) f = Fiber.current conn = self.aconnect(*args) conn.callback { f.resume(conn) } Fiber.yield end
Also aliased as: aconnect
Public Instance Methods
amapped_mget(*keys) { |result| ... }
click to toggle source
adapted from em-redis' implementation to use the asynchronous version of mget
# File lib/em-synchrony/em-redis.rb, line 48 def amapped_mget(*keys) self.amget(*keys) do |response| result = {} response.each do |value| key = keys.shift result.merge!(key => value) unless value.nil? end yield result if block_given? end end
call_command(argv, &blk)
click to toggle source
# File lib/em-synchrony/em-redis.rb, line 28 def call_command(argv, &blk) # async commands are 'a' prefixed if (argv.first[0] == 'a') && !SYNC.include?(argv.first.to_s) argv[0] = argv[0].to_s.slice(1,argv[0].size) old_call_command(argv, &blk) else # wrap response blocks into fiber callbacks # to emulate the sync api f = Fiber.current blk = proc { |v| v } if !block_given? clb = proc { |v| f.resume(blk.call(v)) } old_call_command(argv, &clb) Fiber.yield end end
Also aliased as: old_call_command
mapped_mget(*keys)
click to toggle source
# File lib/em-synchrony/em-redis.rb, line 59 def mapped_mget(*keys) f = Fiber.current self.amapped_mget(*keys) do |values| f.resume(values) end Fiber.yield end