[#1296] writecache: Add count limit

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-08-06 15:09:12 +03:00 committed by Evgenii Stratonikov
parent 36efccd862
commit 08b1f18bca
10 changed files with 65 additions and 20 deletions

View file

@ -29,6 +29,9 @@ type options struct {
// maxCacheSize is the maximum total size of all objects saved in cache (DB + FS).
// 1 GiB by default.
maxCacheSize uint64
// maxCacheCount is the maximum total count of all object saved in cache.
// 0 (no limit) by default.
maxCacheCount uint64
// objCounters contains atomic counters for the number of objects stored in cache.
objCounters counters
// maxBatchSize is the maximum batch size for the small object database.
@ -108,6 +111,13 @@ func WithMaxCacheSize(sz uint64) Option {
}
}
// WithMaxCacheCount sets maximum write-cache objects count.
func WithMaxCacheCount(v uint64) Option {
return func(o *options) {
o.maxCacheCount = v
}
}
// WithMaxBatchSize sets max batch size for the small object database.
func WithMaxBatchSize(sz int) Option {
return func(o *options) {