Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The initial problem: we use GitHub API and to save on API limits we want to use HTTP caching, but with the current
Faraday::HttpCache::Storage
implementation (one cache key per URL) caching of GitHub API endpoints likehttps://api.github.com/user
is impossible since for every request we are fetching an array of all requests for all our users. Limiting the number of cached entries per key from #121 is also not an option in this case.So, the only way to cache GitHub API for us is implementing different storage strategy. That is what this PR is about.
This PR Introduced a new
strategy
option to support different cache storage strategies:Faraday::HttpCache::Strage
toFaraday::HttpCache::Strategies::ByUrl
.Faraday::HttpCache::Strategies::ByVary
strategy uses headers fromVary
header to generate cache keys. It also uses the index withVary
headers mapped to the request URL.Faraday::HttpCache::Strage
class was deprecated.Related #112
Part of #127