feat(lru): update lru clean work

This commit is contained in:
HuangJiaLuo 2021-10-11 19:01:24 +08:00
parent 73e91b3ff0
commit 922fae0f78
2 changed files with 6 additions and 4 deletions

View File

@ -3,7 +3,6 @@ package lru
import (
"context"
"gitee.com/timedb/wheatCache/pkg/event"
"gitee.com/timedb/wheatCache/pkg/logx"
"time"
)
@ -22,9 +21,9 @@ func (lru *SingleCache) cleanWork() {
lruCleanEvent.SetValue(WorkFuncEventKey, work)
lru.lruCleanProduce.Call(cxt, lruCleanEvent)
_, err := lruCleanEvent.StartWaitEvent(20 * time.Minute) //常量
_, err := lruCleanEvent.StartWaitEvent(defaultWaitTime)
if err != nil {
logx.With(cxt, ).Error("cleanWork err: %v", err)
//logx.With(cxt, ).Error("cleanWork err: %v", err)
}
}

View File

@ -4,6 +4,7 @@ import (
"gitee.com/timedb/wheatCache/pkg/proto"
"gitee.com/timedb/wheatCache/pkg/structure"
"sync"
"time"
)
type SingleWorkFunc func() interface{}
@ -24,7 +25,9 @@ const (
defaultLruClearSize = 0.5 * 1024 * 1024 * 1024 * 8
defaultLruEventDriver = 2000
)
const (
defaultWaitTime = 20 * time.Minute
)
type CacheInterface interface {
Del() error
Get(key *proto.BaseKey) (structure.KeyBaseInterface, bool)