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

How do I limit cache disk usage? #573

Open
acejam opened this issue Nov 5, 2024 · 5 comments
Open

How do I limit cache disk usage? #573

acejam opened this issue Nov 5, 2024 · 5 comments

Comments

@acejam
Copy link

acejam commented Nov 5, 2024

Hello,

i'd like to use Souin with Caddy and leverage one of the disk-based storage adapters - such as Badger or NutsDB.

In an effort to prevent "out of disk" system errors, how can I limit the amount of disk space that can be used by the cache?

@darkweak
Copy link
Owner

darkweak commented Nov 6, 2024

Hey @acejam I think that's not possible ATM with these storages. Maybe we could implement the directory size in the simplefs storage https://github.com/darkweak/storages.

@acejam
Copy link
Author

acejam commented Nov 6, 2024

Hey @acejam I think that's not possible ATM with these storages. Maybe we could implement the directory size in the simplefs storage https://github.com/darkweak/storages.

Thanks for the idea. Is the size parameter not used for this already? https://github.com/darkweak/storages/blob/main/simplefs/simplefs.go#L73

@darkweak
Copy link
Owner

darkweak commented Nov 6, 2024

The size is about the number of objects to store but it doesn't limit the filesystem size.

@acejam
Copy link
Author

acejam commented Dec 4, 2024

Hi @darkweak - it looks like this PR that you're working on might help? darkweak/storages#20

I would be interested in testing this.

@darkweak
Copy link
Owner

darkweak commented Dec 8, 2024

Hey @acejam you should be able to use it using

{
    cache {
        ttl 86400s
        simplefs {
            path /somewhere/files/path
            directory_size 1MB # to limit to 1 megabyte
        }
    }
}
xcaddy build .... --with github.com/darkweak/storages/simplefs/caddy@08ca1166d784ef00cc8909f65ce5b9feda12f0e2 --with github.com/darkweak/storages/simplefs@08ca1166d784ef00cc8909f65ce5b9feda12f0e2

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

No branches or pull requests

2 participants