Skip to content
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

Revert Caching (#177) (fixes #239) #240

Merged
merged 1 commit into from
Jul 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,28 +265,6 @@ There's a little more to it, but that's the core idea!
* [Full parallel HTTP fetcher example](https://github.com/httprb/http.rb/wiki/Parallel-requests-with-Celluloid%3A%3AIO)
* See also: [Celluloid::IO](https://github.com/celluloid/celluloid-io)

### Caching

http.rb provides caching of HTTP request (per
[RFC 7234](https://tools.ietf.org/html/rfc7234)) when configured to do
so.

```ruby
require "http"

http = HTTP.cache(:metastore => "file:/var/cache/my-app-http/meta",
:entitystore => "file:/var/cache/my-app-http/entity")

http.get("http://example.com/") # makes request
http.get("http://example.com/") # skips making request and returns
# previously cached response
```

http.rb's caching is backed by
[rack-cache's excellent storage subsystem](http://rtomayko.github.io/rack-cache/storage.html). Any
storage URL supported by rack-cache is supported by http.rb's cache.


### Timeouts

By default, HTTP does not timeout on a request. You can enable per operation
Expand Down
146 changes: 0 additions & 146 deletions lib/http/cache.rb

This file was deleted.

100 changes: 0 additions & 100 deletions lib/http/cache/headers.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/http/cache/null_cache.rb

This file was deleted.

8 changes: 0 additions & 8 deletions lib/http/chainable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@ def follow(opts = {})
# @see #follow
alias_method :with_follow, :follow

def cache(cache)
branch default_options.with_cache(cache)
end

# @deprecated will be removed in 1.0.0
# @see #cache
alias_method :with_cache, :cache

# Make a request with the given headers
# @param headers
def headers(headers)
Expand Down
10 changes: 2 additions & 8 deletions lib/http/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,13 @@ def request(verb, uri, opts = {})
end
end

# Perform a single (no follow) HTTP request
def perform(req, options)
options.cache.perform(req, options) do |r, opts|
make_request(r, opts)
end
end

# @!method persistent?
# @see Options#persistent?
# @return [Boolean] whenever client is persistent
def_delegator :default_options, :persistent?

def make_request(req, options)
# Perform a single (no follow) HTTP request
def perform(req, options)
verify_connection!(req.uri)

@state = :dirty
Expand Down
3 changes: 0 additions & 3 deletions lib/http/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class StateError < ResponseError; end
# Generic Timeout error
class TimeoutError < Error; end

# Generic Cache error
class CacheError < Error; end

# Header name is invalid
class InvalidHeaderNameError < Error; end
end
Loading