-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching #177
Caching #177
Conversation
Huge! Some cleanups and refactorings and would be good to go. :D |
@@ -23,7 +23,7 @@ end | |||
require "yardstick/rake/verify" | |||
Yardstick::Rake::Verify.new do |verify| | |||
verify.require_exact_threshold = false | |||
verify.threshold = 58 | |||
verify.threshold = 58.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this not support >= 50
or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is. And verify.threshold = 58.1
in conjunction with verify.require_exact_threshold = false
(above) means >= 58.1
. We bump it up to try to enforce ourselves to "keep moving forward" to the 100% API documentation coverage :D
Yeah, I'll second huge... looks interesting though. |
It is pretty big but mostly self contained. Hopefully that will make it easier to understand. I'm fixing many of the RuboCop atm. (Pretty sure it hates me as much as i despise it.:) ) Those issues are why the build is broken (the tests already pass) so it should go green with that commit. I'll integrate any feed back asap so comment away. |
\o/ I would replace the locking InMemoryStore with a https://github.com/ruby-concurrency/thread_safe collection, and maybe constantize the most use Strings for a performance boost. Thanks for taking this over :) |
@Asmod4n, no problem. Thanks for getting it started. |
@@ -59,3 +59,6 @@ Style/StringLiterals: | |||
|
|||
Style/TrivialAccessors: | |||
Enabled: false | |||
|
|||
Style/AlignParameters: | |||
Enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not disable this cop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I think this rule encourages harder to read code but it is your house. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It encourages consistency of alignment 😜
@pezra Can you please rename:
Also, IMO |
@tarcieri, thanks for reviewing! I change the file loading behavior so that rack, etc is not required until caching is enabled. For example, |
Seems good, thanks! Will wait to hear what @ixti says |
@@ -26,6 +26,7 @@ group :test do | |||
gem "rspec-its" | |||
gem "rubocop" | |||
gem "yardstick" | |||
gem "fakefs", :require => "fakefs/safe" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like not used (and thus useless) dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was left over from a failed approach to testing the caching stuff. Removed.
Please, move |
Where you think they belong. :) I prefer to put the important part of the tests front and center and leave the less interesting support structures below the fold. It's your code base, though, so i'll do that. |
@pezra I mean following: describe :a do
let(:b) { 1 }
describe :c do
let(:d) { 2 }
end
end
I just prefer to read specs from top to the bottom. And it's a bit inconvenient to me to scroll down to understand "initial" data. :D |
In other words. |
Of course. However, if a spec's purpose cannot be understood without referring to the let definitions i consider that a naming failure. Such failures are, imo, better fixed by finding highly indicative names rather than rearranging things so that the glossary comes first. |
@ixti, i think all the issues you noted are sorted out now. |
@@ -80,6 +82,8 @@ def initialize(verb, uri, headers = {}, proxy = {}, body = nil, version = "1.1") | |||
|
|||
@headers["Host"] ||= default_host | |||
@headers["User-Agent"] ||= USER_AGENT | |||
now = Time.now | |||
@headers["Date"] = now.httpdate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clients SHOULD only send a Date header field in messages that include an entity-body, as in the case of the PUT and POST requests, and even then it is optional. A client without a clock MUST NOT send a Date header field in a request.
The HTTP-date sent in a Date header SHOULD NOT represent a date and time subsequent to the generation of the message. It SHOULD represent the best available approximation of the date and time of message generation, unless the implementation has no means of generating a reasonably accurate date and time. In theory, the date ought to represent the moment just before the entity is generated. In practice, the date can be generated at any time during the message origination without affecting its semantic value.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18
So, looks like this should go to Request::Caching
instead. And also we MUST not override headers if they were explicitly given by user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm not sure if this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
I have merged PR into master. Thanks! |
Yay! Thanks @ixti. |
Implementation of HTTP caching using rake-cache's persistance layer. Based on @Asmod4n's initial pass (https://github.com/Asmod4n/http/compare/caching) but much has changed. :) Addresses issue #77.