Permalink
Browse files

Take a shot at multi_get

  • Loading branch information...
1 parent b5e0bea commit 4e3414039af7405ee0db379254cea54d7b478eae @joshuabates joshuabates committed Apr 25, 2012
Showing with 10 additions and 1 deletion.
  1. +9 −0 lib/cacher.rb
  2. +1 −1 lib/cacher/version.rb
View
@@ -144,6 +144,15 @@ def get(key, options={}, &blk)
unmarshal_value(cached)
end
+ def get_multi(keys)
+ cached_results = cache.read_multi(keys.map { |k| prepare_key(k) }).inject({}) do |results, (key, value)|
+ results[key] = unmarshal_value(value)
+ results
+ end
+
+ keys.map { |key| cached_results[prepare_key(key)] }
+ end
+
def set(key, options={}, &blk)
val = do_block(&blk)
cache_set(key, marshal_value(val), options)
@@ -1,5 +1,5 @@
module Cacher
def self.version
- '0.2.0'
+ '0.2.1'
end
end

0 comments on commit 4e34140

Please sign in to comment.