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

Introduce new Vary strategy #130

Merged
merged 4 commits into from May 31, 2022
Merged

Introduce new Vary strategy #130

merged 4 commits into from May 31, 2022

Conversation

skryukov
Copy link
Contributor

@skryukov skryukov commented May 20, 2022

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 like https://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:

  • The original strategy was moved from Faraday::HttpCache::Strage to Faraday::HttpCache::Strategies::ByUrl.
  • The new Faraday::HttpCache::Strategies::ByVary strategy uses headers from Vary header to generate cache keys. It also uses the index with Vary headers mapped to the request URL.
  • Faraday::HttpCache::Strage class was deprecated.

Related #112
Part of #127

@skryukov skryukov marked this pull request as ready for review May 25, 2022 19:01
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
lib/faraday/http_cache/strategies/by_vary.rb Show resolved Hide resolved
spec/storage_spec.rb Outdated Show resolved Hide resolved
@garaujodev garaujodev merged commit 422f3fe into sourcelevel:master May 31, 2022
@skryukov skryukov deleted the vary-strategy branch May 31, 2022 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants