Permalink
Browse files

use memcache for cache & session store in production & staging enviro…

…nments
  • Loading branch information...
1 parent 123020f commit d904864f69c646c56d59d14851f7a86e9ea3872d @yannlugrin yannlugrin committed Mar 7, 2012
Showing with 11 additions and 10 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +1 −1 config/environments/production.rb
  4. +1 −1 config/environments/staging.rb
  5. +6 −8 config/initializers/session_store.rb
View
@@ -26,6 +26,7 @@ end
group :production, :staging do
gem 'pg'
gem 'airbrake'
+ gem 'dalli'
end
# Development environment dependencies (also needed by test environement)
View
@@ -50,6 +50,7 @@ GEM
sass (~> 3.1)
cookiejar (0.3.0)
daemons (1.1.8)
+ dalli (1.1.4)
diff-lcs (1.1.3)
em-hiredis (0.1.1)
hiredis (~> 0.4.0)
@@ -268,6 +269,7 @@ DEPENDENCIES
bootstrap-sass (~> 2.0.1)
bourbon (~> 1.4)
compass (~> 0.12.rc)
+ dalli
factory-girl-matchers (>= 1.0.0.rc1)
factory_girl_rails
faker
@@ -43,7 +43,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
- # config.cache_store = :mem_cache_store
+ config.cache_store = :dalli_store, { namespace: 'stopwatch_cache' }
# Enable serving of images, stylesheets, and JavaScripts from an asset server
config.action_controller.asset_host = Proc.new do |source|
@@ -43,7 +43,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production
- # config.cache_store = :mem_cache_store
+ config.cache_store = :dalli_store, { namespace: 'stopwatch_cache' }
# Enable serving of images, stylesheets, and JavaScripts from an asset server
config.action_controller.asset_host = Proc.new do |source|
@@ -1,8 +1,6 @@
-# Be sure to restart your server when you modify this file.
-
-Stopwatch::Application.config.session_store :cookie_store, key: '_stopwatch_session'
-
-# Use the database for sessions instead of the cookie-based default,
-# which shouldn't be used to store highly confidential information
-# (create the session table with "rails generate session_migration")
-# Stopwatch::Application.config.session_store :active_record_store
+if Rails.env.production? || Rails.env.staging?
+ require 'action_dispatch/middleware/session/dalli_store'
+ Stopwatch::Application.config.session_store :dalli_store, namespace: '_stop_watch_session', key: '_stopwatch_session', expire_after: 1.day
+else
+ Stopwatch::Application.config.session_store :cookie_store, key: '_stop_watch_session'
+end

0 comments on commit d904864

Please sign in to comment.