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

Add MAX_CACHE_SIZE config #344

Merged
merged 4 commits into from
Jun 29, 2024
Merged

Add MAX_CACHE_SIZE config #344

merged 4 commits into from
Jun 29, 2024

Conversation

n0vad3v
Copy link
Member

@n0vad3v n0vad3v commented Jun 28, 2024

This PR adds MAX_CACHE_SIZE in config, which will solve the following issues:

MAX_CACHE_SIZE is set in number, with unit of MiB, the default value is 0, which will remain current setup, if this value is set, for example 50, then a background task will run alongside with WebP Server Go, that task will ensure the following directories will be below 50MiB, seperately.

  • ./metadata
  • ./exhaust
  • ./remote-raw

If any of the above directories' size goes above setting value, the oldest file will be deleted to make space.

Note, this will keep the above directories' size seperately, so there can be the following situation with total size of 101MiB.

  • ./metadata (4MiB)
  • ./exhaust (48MiB)
  • ./remote-raw (49MiB)

Also, this PR fixes a bug where CACHE_TTL should be WEBP_CACHE_TTL in environment variable.

@n0vad3v n0vad3v requested a review from BennyThink June 28, 2024 11:59
Copy link


ghcr.io/webp-sh/webp_server_go (debian 12.5)
============================================
Total: 0 (HIGH: 0, CRITICAL: 0)


if err != nil && err != os.ErrNotExist {
log.Warn("Failed to clear remote raw cache")
}
time.Sleep(1 * time.Minute)
Copy link
Member

Choose a reason for hiding this comment

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

Use time.Ticker?

@n0vad3v n0vad3v merged commit 89ea0af into master Jun 29, 2024
6 checks passed
@n0vad3v n0vad3v deleted the max-cache-size branch June 29, 2024 08:42
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