Permalink
Browse files

Rails 3 support

  • Loading branch information...
1 parent b9f94d6 commit 5cbc60e2520a96c1e2c108f485a726d4ad6f408e @winton committed Oct 25, 2011
Showing with 12 additions and 2 deletions.
  1. +11 −2 lib/background_cache.rb
  2. +1 −0 lib/background_cache/daemon.rb
View
13 lib/background_cache.rb
@@ -18,10 +18,18 @@
module BackgroundCache
class AppInstance
- include ActionController::UrlWriter
+ if defined?(ActionDispatch::Routing::UrlFor)
+ include ActionDispatch::Routing::UrlFor
+ elsif defined?(ActionController::UrlWriter)
+ include ActionController::UrlWriter
+ end
include Rack::Test::Methods
def app
- ActionController::Dispatcher.new
+ if defined?(Rails::Application)
+ Rails::Application.subclasses.first
+ elsif defined?(ActionController::Dispatcher)
+ ActionController::Dispatcher.new
+ end
end
end
@@ -42,6 +50,7 @@ def self.cache!(group=nil, instance=nil)
end
def self.manual(cache, instance=nil)
+ ENV['BACKGROUND_CACHE'] = '1'
unless instance
instance = self.boot
end
View
1 lib/background_cache/daemon.rb
@@ -31,6 +31,7 @@ def initialize(root)
while true
request = redis.lpop('background_cache:request')
if request
+ puts request.inspect
Timeout.timeout(60) do
request = Yajl::Parser.parse(request)
channel = request.delete('channel')

0 comments on commit 5cbc60e

Please sign in to comment.