Sha256: 58e08a0251ae662115fe11daa6f724d5b3321355c234b95aa0a2e71a15ec71bf

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 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

  private

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

    @connect.merge :driver => :hiredis
  end

  def self.connection
    @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.5 lib/auth_redis_user_connector/redis_user_connector.rb