Class: Opinions::RedisBackend
- Inherits:
-
Object
- Object
- Opinions::RedisBackend
- Defined in:
- lib/opinions.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
- #keys_matching(argument) ⇒ Object
- #read_key(key_name) ⇒ Object
- #read_sub_key(key_name, key) ⇒ Object
- #remove_sub_keys(key_pairs) ⇒ Object
- #write_keys(key_hashes) ⇒ Object
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
60 61 62 |
# File 'lib/opinions.rb', line 60 def redis @redis end |
Instance Method Details
#keys_matching(argument) ⇒ Object
93 94 95 |
# File 'lib/opinions.rb', line 93 def keys_matching(argument) redis.keys(argument) end |
#read_key(key_name) ⇒ Object
77 78 79 |
# File 'lib/opinions.rb', line 77 def read_key(key_name) redis.hgetall(key_name) end |
#read_sub_key(key_name, key) ⇒ Object
81 82 83 |
# File 'lib/opinions.rb', line 81 def read_sub_key(key_name, key) redis.hget(key_name, key) end |
#remove_sub_keys(key_pairs) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/opinions.rb', line 85 def remove_sub_keys(key_pairs) redis.multi do key_pairs.each do |key_name, key| redis.hdel(key_name, key.to_s) end end end |
#write_keys(key_hashes) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/opinions.rb', line 62 def write_keys(key_hashes) redis.multi do key_hashes.each do |key_name, hash| write_key(key_name, hash) end end end |