]> git.openstreetmap.org Git - rails.git/blobdiff - config/initializers/memcached.rb
Add memcache support
[rails.git] / config / initializers / memcached.rb
diff --git a/config/initializers/memcached.rb b/config/initializers/memcached.rb
new file mode 100644 (file)
index 0000000..03066a8
--- /dev/null
@@ -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