No commit activity in last 3 years
No release in over 3 years
write-through cache store that allows you to chain multiple cache stores together
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

ActiveSupport::Cache::CascadeStore

Hopefully this cache store is merged upstream into core with this pull request. In the meantime, packaging this up as a gem for easy access.

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, or to put lower latency stores in front of other cache stores.

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

For more background info, check out this blog post: Writing a Custom Rails Cache Store

Rails Configuration

Add to your Gemfile:

gem 'activesupport-cascadestore'

In your production.rb:

# configure with stores you want to use.
config.cache_store = [:cascade_store, :stores => [
  :memory_store,
  :file_store
]]

Development

To run tests

ruby -Itest test/caching_test.rb

License

Same license as Rails