Add memcache support
This commit is contained in:
parent
696fbb4e16
commit
2fd52ddf60
3 changed files with 16 additions and 1 deletions
|
@ -26,6 +26,9 @@ Rails::Initializer.run do |config|
|
||||||
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
|
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
|
||||||
config.gem 'sanitize'
|
config.gem 'sanitize'
|
||||||
config.gem 'i18n', :version => '>= 0.5.0'
|
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).
|
# 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
|
# :all can be used as a placeholder for all plugins not explicitly named
|
||||||
|
|
|
@ -16,7 +16,10 @@ config.action_view.cache_template_loading = true
|
||||||
# config.logger = SyslogLogger.new
|
# config.logger = SyslogLogger.new
|
||||||
|
|
||||||
# Use a different cache store in production
|
# 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
|
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
# config.action_controller.asset_host = "http://assets.example.com"
|
||||||
|
|
9
config/initializers/memcached.rb
Normal file
9
config/initializers/memcached.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue