Method: Readthis::Cache#write_multi
- Defined in:
- lib/readthis/cache.rb
#write_multi(hash, options = {}) ⇒ Object
Write multiple key value pairs simultaneously. This is an atomic operation that will always succeed and will overwrite existing values.
This is a non-standard, but useful, cache method.
241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/readthis/cache.rb', line 241 def write_multi(hash, = {}) = () values = hash.each_with_object([]) do |(key, value), memo| memo << namespaced_key(key, ) memo << entity.dump(value) end invoke(:write_multi, values) do |store| store.mset(values) end end |