Permalink
Browse files

memcache in production

  • Loading branch information...
1 parent ed9925f commit 2ef4d60f291358c84004f6972ace9d4ab10ff850 @mislav committed May 2, 2012
Showing with 14 additions and 4 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +11 −4 app.rb
View
@@ -21,3 +21,4 @@ gem 'faraday_middleware'
gem 'choices'
gem 'rake'
gem 'never-forget'
+gem 'dalli'
View
@@ -14,6 +14,7 @@ GEM
compass (0.10.6)
haml (>= 3.0.4)
daemons (1.1.2)
+ dalli (2.0.3)
erubis (2.7.0)
eventmachine (0.12.10)
faraday (0.8.0)
@@ -58,6 +59,7 @@ DEPENDENCIES
builder
choices
compass
+ dalli
faraday_middleware
haml
i18n
View
@@ -8,7 +8,10 @@
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/integer/time'
require 'active_support/core_ext/time/acts_like'
-require 'lib/instagram/failsafe_store'
+# required for dalli:
+require 'active_support/core_ext/string/encoding'
+require 'active_support/cache'
+require 'active_support/cache/dalli_store'
require 'digest/md5'
require 'haml'
require 'sass'
@@ -38,9 +41,13 @@
config.send("#{key}=", value)
end
- config.cache = Instagram::FailsafeStore.new settings.cache_dir,
- namespace: 'instagram', expires_in: settings.expires.api_cache,
- exceptions: %w[Faraday::Error::ClientError Timeout::Error]
+ cache_options = { namespace: 'instagram', expires_in: settings.expires.api_cache }
+
+ if settings.production?
+ config.cache = ActiveSupport::Cache::DalliStore.new cache_options.merge(compress: true)
+ else
+ config.cache = ActiveSupport::Cache::FileStore.new settings.cache_dir, cache_options
+ end
end
module Stats

0 comments on commit 2ef4d60

Please sign in to comment.