forked from p93542168/wheat-cache
35 lines
701 B
Go
35 lines
701 B
Go
package lru
|
|
|
|
import (
|
|
"gitee.com/timedb/wheatCache/pkg/proto"
|
|
"gitee.com/timedb/wheatCache/pkg/structure"
|
|
"sync"
|
|
)
|
|
|
|
type SingleWorkFunc func() interface{}
|
|
|
|
const (
|
|
OptionEventName = "operateEvent"
|
|
CleanEventName = "clearEvent"
|
|
WorkFuncEventKey = "workFunc"
|
|
)
|
|
|
|
var (
|
|
lruCacheOnce sync.Once
|
|
lruCache *SingleCache
|
|
)
|
|
|
|
const (
|
|
lruMaxSize = 1 * 1024 * 1024 * 1024 * 8
|
|
lruClearSize = 0.5 * 1024 * 1024 * 1024 * 8
|
|
lruEventDriver = 2000
|
|
)
|
|
|
|
type CacheInterface interface {
|
|
Del() error
|
|
Get(key *proto.BaseKey) (structure.KeyBaseInterface, bool)
|
|
Add(key *proto.BaseKey, val structure.KeyBaseInterface)
|
|
UpdateLruSize(length structure.UpdateLength)
|
|
DelByKey(key *proto.BaseKey) error
|
|
}
|