class RedQueen::Client
Public Class Methods
new(prefix, client)
click to toggle source
# File lib/redqueen/client.rb, line 3 def initialize prefix, client @prefix = prefix @client = client end
Public Instance Methods
get(key)
click to toggle source
# File lib/redqueen/client.rb, line 8 def get key unpack @client.get prefix(key) end
mget(keys)
click to toggle source
# File lib/redqueen/client.rb, line 12 def mget keys return [] if keys.nil? or keys.empty? @client.mget(keys.map{|k| prefix(k)}).map{|v| unpack(v)} end
mset(hash)
click to toggle source
# File lib/redqueen/client.rb, line 21 def mset hash @client.mset hash.flat_map{|k, v| [prefix(k), v.to_msgpack]} end
pipelined() { |self| ... }
click to toggle source
# File lib/redqueen/client.rb, line 45 def pipelined @client.pipelined do yield self end end
prefix(key)
click to toggle source
# File lib/redqueen/client.rb, line 51 def prefix key [@prefix, key].join(':') end
select(index)
click to toggle source
# File lib/redqueen/client.rb, line 41 def select index @client.select index end
set(key, value)
click to toggle source
# File lib/redqueen/client.rb, line 17 def set key, value @client.set prefix(key), value.to_msgpack end
unpack(item)
click to toggle source
# File lib/redqueen/client.rb, line 55 def unpack item return nil if item.nil? MessagePack.unpack item end
zadd(key, *args)
click to toggle source
# File lib/redqueen/client.rb, line 25 def zadd key, *args @client.zadd prefix(key), args.flatten.map{|item| [item[:score], item[:member].to_msgpack]} end
zinterstore(key, sources)
click to toggle source
# File lib/redqueen/client.rb, line 37 def zinterstore key, sources @client.zinterstore prefix(key), sources.map{|s| prefix(s)} end
zrange(key, start, finish)
click to toggle source
# File lib/redqueen/client.rb, line 29 def zrange key, start, finish @client.zrange(prefix(key), start, finish).map{|i| unpack(i)} end
zrevrange(key, start, finish)
click to toggle source
# File lib/redqueen/client.rb, line 33 def zrevrange key, start, finish @client.zrevrange(prefix(key), start, finish).map{|i| unpack(i)} end