Class: ActiveOrm::Redis::Hash
Class 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
Class Method Details
.all(key) ⇒ Object
18 19 20 21 22 |
# File 'lib/active_orm/redis/hash.rb', line 18 def all(key) value = client.hgetall(normalize_key(key)) value = (value) if evaluate? value end |
.count(key) ⇒ Object
40 41 42 |
# File 'lib/active_orm/redis/hash.rb', line 40 def count(key) client.hlen(normalize_key(key)) end |
.create(key, field, value) ⇒ Object
48 49 50 |
# File 'lib/active_orm/redis/hash.rb', line 48 def create(key, field, value) client.hset(normalize_key(key), field, value) end |
.create!(key, field, value) ⇒ Object
52 53 54 |
# File 'lib/active_orm/redis/hash.rb', line 52 def create!(key, field, value) client.hsetnx(normalize_key(key), field, value) end |
.create_each(key, *args) ⇒ Object
56 57 58 |
# File 'lib/active_orm/redis/hash.rb', line 56 def create_each(key, *args) client.hmset(normalize_key(key), args) end |
.destroy(key, *args) ⇒ Object
70 71 72 |
# File 'lib/active_orm/redis/hash.rb', line 70 def destroy(key, *args) client.hdel(normalize_key(key), args) end |
.exists?(key, field) ⇒ Boolean
44 45 46 |
# File 'lib/active_orm/redis/hash.rb', line 44 def exists?(key, field) client.hexists(normalize_key(key), field) end |
.find(key, field) ⇒ Object
6 7 8 9 10 |
# File 'lib/active_orm/redis/hash.rb', line 6 def find(key, field) value = client.hget(normalize_key(key), field) value = (value) if evaluate? value end |
.find_each(key, *args) ⇒ Object
12 13 14 15 16 |
# File 'lib/active_orm/redis/hash.rb', line 12 def find_each(key, *args) value = client.hmget(normalize_key(key), args) value = (value) if evaluate? value end |
.increment(key, field, value) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/active_orm/redis/hash.rb', line 60 def increment(key, field, value) normalized_key = normalize_key(key) if value.is_a?(Float) client.hincrbyfloat(normalized_key, field, value) else client.hincrby(normalized_key, field, value) end end |
.keys(key) ⇒ Object
24 25 26 27 28 |
# File 'lib/active_orm/redis/hash.rb', line 24 def keys(key) value = client.hkeys(normalize_key(key)) value = (value) if evaluate? value end |
.scan(key, cursor, opts = {}) ⇒ Object
74 75 76 |
# File 'lib/active_orm/redis/hash.rb', line 74 def scan(key, cursor, opts = {}) client.hdel(normalize_key(key), cursor, opts) end |
.value_length(key, field) ⇒ Object
36 37 38 |
# File 'lib/active_orm/redis/hash.rb', line 36 def value_length(key, field) client.hstrlen(normalize_key(key), field) end |
.values(key) ⇒ Object
30 31 32 33 34 |
# File 'lib/active_orm/redis/hash.rb', line 30 def values(key) value = client.hvals(normalize_key(key)) value = (value) if evaluate? value end |