forked from p93542168/wheat-cache
32 lines
607 B
Go
32 lines
607 B
Go
package lru
|
|
|
|
import (
|
|
"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 string) (structure.KeyBaseInterface, bool)
|
|
Add(key string, val structure.KeyBaseInterface)
|
|
UpdateLruSize(length structure.UpdateLength)
|
|
} |