All checks were successful
DCO action / DCO (pull_request) Successful in 1m7s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m30s
Build / Build Components (pull_request) Successful in 1m56s
Vulncheck / Vulncheck (pull_request) Successful in 1m47s
Tests and linters / Run gofumpt (pull_request) Successful in 3m16s
Tests and linters / Lint (pull_request) Successful in 3m49s
Tests and linters / Staticcheck (pull_request) Successful in 3m49s
Tests and linters / Tests (pull_request) Successful in 3m59s
Tests and linters / gopls check (pull_request) Successful in 4m9s
Tests and linters / Tests with -race (pull_request) Successful in 4m40s
Pre-commit hooks / Pre-commit (push) Successful in 1m17s
Vulncheck / Vulncheck (push) Successful in 1m24s
Build / Build Components (push) Successful in 1m57s
Tests and linters / Run gofumpt (push) Successful in 2m37s
Tests and linters / Tests (push) Successful in 3m1s
Tests and linters / Staticcheck (push) Successful in 3m7s
Tests and linters / Lint (push) Successful in 3m11s
Tests and linters / gopls check (push) Successful in 3m14s
Tests and linters / Tests with -race (push) Successful in 3m25s
OCI image / Build container images (push) Successful in 4m54s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
20 lines
476 B
Go
20 lines
476 B
Go
package writecache
|
|
|
|
func (c *cache) estimateCacheSize() (uint64, uint64) {
|
|
count, size := c.counter.CountSize()
|
|
c.metrics.SetEstimateSize(size)
|
|
c.metrics.SetActualCounters(count)
|
|
return count, size
|
|
}
|
|
|
|
func (c *cache) hasEnoughSpace(objectSize uint64) bool {
|
|
count, size := c.estimateCacheSize()
|
|
if c.maxCacheCount > 0 && count+1 > c.maxCacheCount {
|
|
return false
|
|
}
|
|
return c.maxCacheSize >= size+objectSize
|
|
}
|
|
|
|
func (c *cache) initCounters() {
|
|
c.estimateCacheSize()
|
|
}
|