Skip to content

feat: Make cache TTL configurable #40

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

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

aaronlehmann
Copy link
Collaborator

Add a CACHE_TTL_DAYS env var to control layer cache TTL.

Also, fix int handling in OptionsFromEnv (which is also needed for GIT_CLONE_DEPTH).

@@ -111,6 +111,10 @@ type Options struct {
// It will override CacheRepo if both are specified.
LayerCacheDir string `env:"LAYER_CACHE_DIR"`

// CacheTTLDays is the number of days to use cached layers before
// expiring them. Defaults to 7 days.
CacheTTLDays int `env:"CACHE_TTL_DAYS"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make this a time.Duration instead? Go can parse pretty nice strings like "7d" or "12hr".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that, but since days aren't supported in the format, it's an awkward way to specify long time periods. Okay with me if you prefer that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, you're right I forgot. I think days is fine in that case. It's weird that someone would want to cache for hours anyways.

@kylecarbs
Copy link
Member

@aaronlehmann could you resolve the new conflicts on your branch? Then feel free to auto-merge!

Add a CACHE_TTL_DAYS env var to control layer cache TTL.

Also, fix int handling in OptionsFromEnv (which is also needed for
GIT_CLONE_DEPTH).
@aaronlehmann aaronlehmann force-pushed the configurable-cache-ttl branch from 55cb07e to 59d38c4 Compare July 25, 2023 19:35
@aaronlehmann aaronlehmann merged commit d649732 into coder:main Jul 25, 2023
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