Class: Norton::Objects::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/norton/objects/hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options = {}) ⇒ Hash



6
7
8
9
# File 'lib/norton/objects/hash.rb', line 6

def initialize(key, options = {})
  @key   = key
  @redis = Norton.pools[options[:pool_name] || :default]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/norton/objects/hash.rb', line 4

def key
  @key
end

#redisObject (readonly)

Returns the value of attribute redis.



4
5
6
# File 'lib/norton/objects/hash.rb', line 4

def redis
  @redis
end

Instance Method Details

#clearObject

Redis: DEL



64
65
66
# File 'lib/norton/objects/hash.rb', line 64

def clear
  redis.with { |conn| conn.del(key) }
end

#hdecrby(field, by = 1) ⇒ Object Also known as: decr

Redis: HINCRBY



43
44
45
# File 'lib/norton/objects/hash.rb', line 43

def hdecrby(field, by = 1)
  hincrby(field, -by)
end

#hdel(*field) ⇒ Object Also known as: delete

Redis: HDEL



31
32
33
# File 'lib/norton/objects/hash.rb', line 31

def hdel(*field)
  redis.with { |conn| conn.hdel(key, field) }
end

#hexists(field) ⇒ Object Also known as: include?, has_key?, key?, member?

Redis: HEXISTS



49
50
51
# File 'lib/norton/objects/hash.rb', line 49

def hexists(field)
  redis.with { |conn| conn.hexists(key, field) }
end

#hget(field) ⇒ Object Also known as: get, []

Redis: HGET



18
19
20
# File 'lib/norton/objects/hash.rb', line 18

def hget(field)
  redis.with { |conn| conn.hget(key, field) }
end

#hincrby(field, by = 1) ⇒ Object Also known as: incr

Redis: HINCRBY



37
38
39
# File 'lib/norton/objects/hash.rb', line 37

def hincrby(field, by = 1)
  redis.with { |conn| conn.hincrby(key, field, by) }
end

#hkeysObject Also known as: keys

Redis: HEXISTS



58
59
60
# File 'lib/norton/objects/hash.rb', line 58

def hkeys
  redis.with { |conn| conn.hkeys(key) }
end

#hmget(*field) ⇒ Object Also known as: mget

Redis: HMGET



25
26
27
# File 'lib/norton/objects/hash.rb', line 25

def hmget(*field)
  redis.with { |conn| conn.hmget(key, field) }
end

#hset(field, value) ⇒ Object Also known as: []=

Redis: HSET



12
13
14
# File 'lib/norton/objects/hash.rb', line 12

def hset(field, value)
  redis.with { |conn| conn.hset(key, field, value) }
end