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

feat: add an option to allow using a time based rolling cache #73

Merged

Conversation

airhorns
Copy link
Contributor

This action currently has a pretty conservative approach to caching in order to avoid ever-growing cache sizes that end up being slower than no cache at all. I think that makes sense as a default, but for projects with a lot of dependencies, a cache miss can be really painful. This PR adds a new option for a middle ground that uses more restoreKeys that are less specific like Github recommends in their docs, but periodically expires the cache which puts an upper bound on how long a cache can snowball for. I picked 1 month for the upper bound.

This periodic expiry is accomplished by adding the current year and month of the run to the cache key, so runs will first use a cache exactly for the current lockfile hash, and then only use a cache from the most recent month. There's no global cache that it falls back to in order to avoid unbounded cache size growth. That means the first run of the month will always rebuild the cache from scratch, but I think that's fine to have one slow build a month instead of one slow build every time you change any dependencies.

Thanks for your feedback!

@bahmutov bahmutov changed the base branch from master to monthly-rolling-cache January 31, 2021 14:04
@bahmutov
Copy link
Owner

Makes sense, let me first merge this PR into a local branch to see how it changes all examples.

@bahmutov bahmutov changed the title Add an option to allow using a time based rolling cache feat: add an option to allow using a time based rolling cache Jan 31, 2021
@bahmutov bahmutov merged commit 93c3ade into bahmutov:monthly-rolling-cache Jan 31, 2021
bahmutov added a commit that referenced this pull request Jan 31, 2021
)

Co-authored-by: Harry Brundage <harry.brundage@gmail.com>
@airhorns airhorns deleted the monthly-rolling-cache branch January 31, 2021 15:21
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.

2 participants