Sha256: 1e57f0a3209e94bd9dfd7bec30c06af9264df9f1eb481d0862abc9eddffc98b4

Contents?: true

Size: 701 Bytes

Versions: 1

Compression:

Stored size: 701 Bytes

Contents

require 'redis'

class RedisUserConnector
  def self.connect(hash)
    @connect = hash
  end

  def self.get(key)
    connection.hgetall("#{namespace}:#{key}")
  end

  def self.set(key, *attrs)
    connection.hmset("#{namespace}:#{key}", *(attrs.flatten))
  end

  def self.pub(channel, message)
    connection.publish(channel, message)
  end

  def self.sub(channel, &block)
    connection.subscribe(channel, &block)
  end

  private

  def self.connect_options
    raise "#{name}: Could not establish connection" if @connect.nil? || @connect.empty?

    @connect.merge :driver => :hiredis
  end

  def self.connection
    Redis.new(connect_options)
  end

  def self.namespace
    'user'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auth_redis_user_connector-0.0.7 lib/auth_redis_user_connector/redis_user_connector.rb