Skip to content

Commit

Permalink
fix: asd
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Oct 28, 2023
1 parent b6bcac2 commit 5905847
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/storer/cachestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ func (db *DB) cacheWorker(ctx context.Context) {
select {
case <-overCapTrigger:

var size, capc = db.cacheObj.Size(), db.cacheObj.Capacity()
var (
size = db.cacheObj.Size()
capc = db.cacheObj.Capacity()
)
if size <= capc {
continue
}

evict := (size - capc) + uint64(float64(capc)*0.01) // evict (size - cap) + some buffer
evict := (size - capc)

dur := captureDuration(time.Now())
err := db.Execute(ctx, func(s internal.Storage) error {
Expand Down Expand Up @@ -115,7 +118,10 @@ func (db *DB) CacheShallowCopy(ctx context.Context, store internal.Storage, addr

func (db *DB) triggerCacheEviction() {

var size, capc = db.cacheObj.Size(), db.cacheObj.Capacity()
var (
size = db.cacheObj.Size()
capc = db.cacheObj.Capacity()
)
db.metrics.CacheSize.Set(float64(size))

if size > capc {
Expand Down

0 comments on commit 5905847

Please sign in to comment.