Class: Lite::Redis::Hash
- Inherits:
-
Base
- Object
- Base
- Lite::Redis::Hash
show all
- Defined in:
- lib/lite/redis/hash.rb
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
-
#all(key) ⇒ Object
-
#count(key) ⇒ Object
-
#create(key, field, value) ⇒ Object
-
#create!(key, field, value) ⇒ Object
-
#create_each(key, *args) ⇒ Object
-
#destroy(key, *args) ⇒ Object
-
#exists?(key, field) ⇒ Boolean
-
#find(key, field) ⇒ Object
-
#find_each(key, *args) ⇒ Object
-
#increment(key, field, value) ⇒ Object
-
#keys(key) ⇒ Object
-
#scan(key, cursor, opts = {}) ⇒ Object
-
#value_length(key, field) ⇒ Object
-
#values(key) ⇒ Object
Methods inherited from Base
#initialize, method_missing, #respond_to_method?, #respond_to_missing?
Instance Method Details
#all(key) ⇒ Object
15
16
17
|
# File 'lib/lite/redis/hash.rb', line 15
def all(key)
client.hgetall(key.to_s)
end
|
#count(key) ⇒ Object
31
32
33
|
# File 'lib/lite/redis/hash.rb', line 31
def count(key)
client.hlen(key.to_s)
end
|
#create(key, field, value) ⇒ Object
39
40
41
|
# File 'lib/lite/redis/hash.rb', line 39
def create(key, field, value)
client.hset(key.to_s, field, value)
end
|
#create!(key, field, value) ⇒ Object
43
44
45
|
# File 'lib/lite/redis/hash.rb', line 43
def create!(key, field, value)
client.hsetnx(key.to_s, field, value)
end
|
#create_each(key, *args) ⇒ Object
47
48
49
|
# File 'lib/lite/redis/hash.rb', line 47
def create_each(key, *args)
client.hmset(key.to_s, *args)
end
|
#destroy(key, *args) ⇒ Object
59
60
61
|
# File 'lib/lite/redis/hash.rb', line 59
def destroy(key, *args)
client.hdel(key.to_s, *args)
end
|
#exists?(key, field) ⇒ Boolean
35
36
37
|
# File 'lib/lite/redis/hash.rb', line 35
def exists?(key, field)
client.hexists(key.to_s, field)
end
|
#find(key, field) ⇒ Object
7
8
9
|
# File 'lib/lite/redis/hash.rb', line 7
def find(key, field)
client.hget(key.to_s, field)
end
|
#find_each(key, *args) ⇒ Object
11
12
13
|
# File 'lib/lite/redis/hash.rb', line 11
def find_each(key, *args)
client.hmget(key.to_s, *args)
end
|
#increment(key, field, value) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/lite/redis/hash.rb', line 51
def increment(key, field, value)
if value.is_a?(Float)
client.hincrbyfloat(key.to_s, field, value)
else
client.hincrby(key.to_s, field, value)
end
end
|
#keys(key) ⇒ Object
19
20
21
|
# File 'lib/lite/redis/hash.rb', line 19
def keys(key)
client.hkeys(key.to_s)
end
|
#scan(key, cursor, opts = {}) ⇒ Object
63
64
65
|
# File 'lib/lite/redis/hash.rb', line 63
def scan(key, cursor, opts = {})
client.hdel(key.to_s, cursor, **opts)
end
|
#value_length(key, field) ⇒ Object
27
28
29
|
# File 'lib/lite/redis/hash.rb', line 27
def value_length(key, field)
client.hstrlen(key.to_s, field)
end
|
#values(key) ⇒ Object
23
24
25
|
# File 'lib/lite/redis/hash.rb', line 23
def values(key)
client.hvals(key.to_s)
end
|