Created
December 16, 2010 16:40
-
-
Save JonRowe/743620 to your computer and use it in GitHub Desktop.
Async rack cache monkey patch.... use with caution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'async-rack' | |
require 'rack/cache' | |
module Rack::Cache | |
class Context | |
include AsyncRack::AsyncCallback::Mixin | |
def async_callback(result) | |
response = Response.new(*result) | |
@request ||= Request.new(env.dup.freeze) | |
store response if response.cacheable? | |
super result | |
end | |
def call(env) | |
setup_async env | |
if env['rack.run_once'] | |
call! env | |
else | |
clone.call! env | |
end | |
end | |
end | |
end |
As far as I know
Hi, i am trying to use with Cramp , do you know why i am not receiving any response?
Pass, haven't used Cramp, this requires an async compatible server obviously like thin/rainbows/goliath, and it relies on the async_callback being called from on high. IIRC thin triggers this with a status of -1 and other things use throw :async. I was using async_sinatra with this so that'd be the place to look for clues.
Sorry for the delay in the response especially since I'm not much help :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this still works?