Class: Norton::Objects::Hash
- Inherits:
-
Object
- Object
- Norton::Objects::Hash
- Defined in:
- lib/norton/objects/hash.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
-
#clear ⇒ Object
Redis: DEL.
-
#hdecrby(field, by = 1) ⇒ Object
(also: #decr)
Redis: HINCRBY.
-
#hdel(*field) ⇒ Object
(also: #delete)
Redis: HDEL.
-
#hexists(field) ⇒ Object
(also: #include?, #has_key?, #key?, #member?)
Redis: HEXISTS.
-
#hget(field) ⇒ Object
(also: #get, #[])
Redis: HGET.
-
#hincrby(field, by = 1) ⇒ Object
(also: #incr)
Redis: HINCRBY.
-
#hkeys ⇒ Object
(also: #keys)
Redis: HEXISTS.
-
#hmget(*field) ⇒ Object
(also: #mget)
Redis: HMGET.
-
#hset(field, value) ⇒ Object
(also: #[]=)
Redis: HSET.
-
#initialize(key, options = {}) ⇒ Hash
constructor
A new instance of Hash.
Constructor Details
#initialize(key, options = {}) ⇒ Hash
6 7 8 9 |
# File 'lib/norton/objects/hash.rb', line 6 def initialize(key, = {}) @key = key @redis = Norton.pools[[:pool_name] || :default] end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/norton/objects/hash.rb', line 4 def key @key end |
#redis ⇒ Object (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
#clear ⇒ Object
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 |
#hkeys ⇒ Object 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 |