rails/rails — pull request #5263 by jch (2012-03-04 00:16:52+00:00)
Title: Add ActiveSupport::Cache::CascadeStore

A thread-safe cache store implementation that cascades operations to a
list of other cache stores. It is used to provide fallback cache
stores when primary stores become unavailable. For example, to
initialize a CascadeStore that cascades through MemCacheStore,
MemoryStore, and FileStore:

ActiveSupport::Cache.lookup_store(:cascade_store,
:stores => [
:mem_cache_store,
:memory_store,
:file_store
]
})

Cache operation behavior:

Read: returns first cache hit from :stores, nil if none found

Write/Delete: write/delete through to each cache store in :stores

Increment/Decrement: increment/decrement each store, returning the new
number if any stores was successfully incremented/decremented, nil
otherwise

In my app, I'm using Cascade store with MemCache as the primary store, with MemoryStore as a backup in case memcache is unavailable. What do you guys think?