Class: CacheReduce::CacheStore
- Inherits:
-
Object
- Object
- CacheReduce::CacheStore
- Defined in:
- lib/cache_reduce.rb
Instance Method Summary collapse
-
#read(keys) ⇒ Object
TODO update interface key, period, hours.
- #redis ⇒ Object
- #write(key, value) ⇒ Object
Instance Method Details
#read(keys) ⇒ Object
TODO update interface key, period, hours
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cache_reduce.rb', line 101 def read(keys) # puts "READ: #{keys}" values = {} redis.mget(*keys).each_with_index do |value, i| key = keys[i] value = redis.get(key) values[key] = value ? JSON.parse("[" + value + "]")[0] : nil end values end |
#redis ⇒ Object
117 118 119 |
# File 'lib/cache_reduce.rb', line 117 def redis @redis ||= Redis.new end |
#write(key, value) ⇒ Object
112 113 114 115 |
# File 'lib/cache_reduce.rb', line 112 def write(key, value) # puts "WRITE: #{key} #{value}" redis.set(key, value.to_json) end |