Skip to content

Instantly share code, notes, and snippets.

@wpeterson
Created November 23, 2010 23:43
Show Gist options
  • Save wpeterson/712792 to your computer and use it in GitHub Desktop.
Save wpeterson/712792 to your computer and use it in GitHub Desktop.
Example of Segmenting Caches in Rails Apps
revision_file = Rails.root.join('REVISION')
if File.exist?(revision_file)
revision = File.read(revision_file).match /[a-f,0-9]{6}$/
end
config.cache_store = :mem_cache_store, memcache_host, {
:namespace => "volatile-#{ revision ? revision[0] : '0'}"
}
config.action_controller.cache_store = :mem_cache_store, memcache_host, {
:namespace => 'stable'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment