Module: RedisHelpers

Defined in:
lib/helpers/redis.rb

Instance Method Summary collapse

Instance Method Details

#remotellen(lists) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/helpers/redis.rb', line 3

def remotellen(lists)
  @remote_redis = Redis.new(
    :host => $redis.hget('config', 'remoteredis:host'),
    :port => $redis.hget('config', 'remoteredis:port'),
    :password => nil || $redis.hget('config', 'remoteredis:password')
  )
  result = Hash.new
  lists.each do |list|
    result.merge!(list => @remote_redis.llen(list))
  end
  return result
end

#remotelpush(list, value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/helpers/redis.rb', line 16

def remotelpush(list, value)
  @remote_redis = Redis.new(
    :host => $redis.hget('config', 'remoteredis:host'),
    :port => 6379 || $redis.hget('config', 'remoteredis:port'),
    :password => nil || $redis.hget('config', 'remoteredis:password')
  )
  begin
    @remote_redis.lpush(list, value)
    return { success => "true" }
  rescue
    return { success => "false" }
  end
end