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) ⇒ 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

#keyObject (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

#clearObject

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

#hkeysObject 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

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

Redis: HMGET



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

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

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

Redis: HSET



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

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