Sha256: 874988d1352e121633bc371dd265ef358e744aa061e0bebc83d75b1c7b740b5b

Contents?: true

Size: 834 Bytes

Versions: 21

Compression:

Stored size: 834 Bytes

Contents

# encoding: utf-8
module RedisHelpers
  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

  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
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gaptool-server-0.3.0 lib/helpers/redis.rb