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 · 6 comments · May be fixed by darkweak/storages#20
Open

How do I limit cache disk usage? #573

acejam opened this issue Nov 5, 2024 · 6 comments · May be fixed by darkweak/storages#20

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

@darkweak darkweak linked a pull request Dec 24, 2024 that will close this issue
1 task
@jackalcooper
Copy link

jackalcooper commented Jan 7, 2025

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

I'd like to test the latest simplefs but couldn't get a version of caddy recognizes the directory_size directive. Here is my xcaddy command:

xcaddy build --with github.com/caddyserver/replace-response \
  --with github.com/darkweak/souin/plugins/caddy \
  --with github.com/darkweak/storages/simplefs/caddy@0bf47f3c81001be1c940558e22cff9059c7ddd1f \
  --with github.com/darkweak/storages/simplefs@0bf47f3c81001be1c940558e22cff9059c7ddd1f

and the list-modules --versions output

cache v1.7.5
http.handlers.cache v1.7.5
http.handlers.replace_response v0.0.0-20241211194404-3865845790a7
storages.cache.simplefs v0.0.12-0.20241224133404-0bf47f3c8100

  Non-standard modules: 4

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 a pull request may close this issue.

3 participants