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.
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) ⇒ Hash
constructor
A new instance of Hash.
Constructor Details
#initialize(key) ⇒ Hash
Returns a new instance of Hash.
6 7 8 |
# File 'lib/norton/objects/hash.rb', line 6 def initialize(key) @key = key 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 |
Instance Method Details
#clear ⇒ Object
Redis: DEL
63 64 65 |
# File 'lib/norton/objects/hash.rb', line 63 def clear Norton.redis.with { |conn| conn.del(key) } end |
#hdecrby(field, by = 1) ⇒ Object Also known as: decr
Redis: HINCRBY
42 43 44 |
# File 'lib/norton/objects/hash.rb', line 42 def hdecrby(field, by = 1) hincrby(field, -by) end |
#hdel(*field) ⇒ Object Also known as: delete
Redis: HDEL
30 31 32 |
# File 'lib/norton/objects/hash.rb', line 30 def hdel(*field) Norton.redis.with { |conn| conn.hdel(key, field) } end |
#hexists(field) ⇒ Object Also known as: include?, has_key?, key?, member?
Redis: HEXISTS
48 49 50 |
# File 'lib/norton/objects/hash.rb', line 48 def hexists(field) Norton.redis.with { |conn| conn.hexists(key, field) } end |
#hget(field) ⇒ Object Also known as: get, []
Redis: HGET
17 18 19 |
# File 'lib/norton/objects/hash.rb', line 17 def hget(field) Norton.redis.with { |conn| conn.hget(key, field) } end |
#hincrby(field, by = 1) ⇒ Object Also known as: incr
Redis: HINCRBY
36 37 38 |
# File 'lib/norton/objects/hash.rb', line 36 def hincrby(field, by = 1) Norton.redis.with { |conn| conn.hincrby(key, field, by) } end |
#hkeys ⇒ Object Also known as: keys
Redis: HEXISTS
57 58 59 |
# File 'lib/norton/objects/hash.rb', line 57 def hkeys Norton.redis.with { |conn| conn.hkeys(key) } end |