Add memcache support

This commit is contained in:
Tom Hughes 2011-04-17 18:56:50 +01:00
parent 696fbb4e16
commit 2fd52ddf60
3 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,9 @@ Rails::Initializer.run do |config|
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
config.gem 'sanitize'
config.gem 'i18n', :version => '>= 0.5.0'
if defined?(MEMCACHE_SERVERS)
config.gem 'memcached'
end
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named

View file

@ -16,7 +16,10 @@ config.action_view.cache_template_loading = true
# config.logger = SyslogLogger.new
# Use a different cache store in production
# config.cache_store = :mem_cache_store
if defined?(MEMCACHE_SERVERS)
MEMCACHE = Memcached::Rails.new(MEMCACHE_SERVERS, :binary_protocol => true)
config.cache_store = :mem_cache_store, MEMCACHE
end
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"

View file

@ -0,0 +1,9 @@
if defined?(PhusionPassenger) and defined?(MEMCACHE_SERVERS)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
MEMCACHE = MEMCACHE.clone
RAILS_CACHE = ActiveSupport::Cache::CompressedMemCacheStore.new(MEMCACHE)
ActionController::Base.cache_store = RAILS_CACHE
end
end
end