rails/rails — pull request #10234 by dasch (2013-04-16 11:11:05+00:00)
Title: Allow fetching multiple values from the cache at once

This pull request adds a `#fetch_multi` to the base cache store class. The API works as follows:

```ruby
cache.write("foo", "ding")
cache.fetch_multi("foo", "bar") { |value| value.reverse }
#=> ["ding", "rab"]

cache.read("bar") #=> "rab"
```

The value of the addition is most obvious when dealing with objects which hold state and implement `#cache_key`:

```ruby
content_tag :ul do
cache.fetch_multi(*articles, :namespace => "something") do |article|
# Assume that this is expensive...
content_tag :li, link_to(article.title, article)
end.join
end
```