test(lru): rename SingleCache

This commit is contained in:
bandl 2021-10-04 22:20:58 +08:00
parent e6987546ae
commit 8bcac6f739
1 changed files with 8 additions and 8 deletions

View File

@ -16,7 +16,7 @@ type keyBaseValue struct {
val structure.KeyBaseInterface
}
type singleCache struct {
type SingleCache struct {
maxsize int64 //最大的长度
clearSize int64 // 清理长度
nowSize int64 // 现在的长度
@ -29,7 +29,7 @@ type singleCache struct {
}
// UpdateLruSize 更新现在的长度
func (lru *singleCache) UpdateLruSize(length int64) {
func (lru *SingleCache) UpdateLruSize(length int64) {
atomic.AddInt64(&lru.nowSize, length)
}
@ -61,11 +61,11 @@ func cacheInit() (int64, int64, event.DriverInterface) {
}
// NewLRUCache lru初始化
func NewLRUCache() *singleCache {
func NewLRUCache() *SingleCache {
maxSize, clearSize, lruDrivers := cacheInit()
lruCacheOnce.Do(func() {
_, _, lruDriver := cacheInit()
lru := &singleCache{
lru := &SingleCache{
maxsize: maxSize,
clearSize: clearSize,
nowSize: 0,
@ -82,12 +82,12 @@ func NewLRUCache() *singleCache {
}
// GetDriver 获取驱动
func (lru *singleCache) GetDriver() event.DriverInterface {
func (lru *SingleCache) GetDriver() event.DriverInterface {
return lru.lruDriver
}
//Add 增加
func (lru *singleCache) Add(key string, val structure.KeyBaseInterface) {
func (lru *SingleCache) Add(key string, val structure.KeyBaseInterface) {
keyBaseVal := &keyBaseValue{
key: key,
@ -105,7 +105,7 @@ func (lru *singleCache) Add(key string, val structure.KeyBaseInterface) {
}
// Get 查找key对应的value
func (lru *singleCache) Get(key string) (structure.KeyBaseInterface, bool) {
func (lru *SingleCache) Get(key string) (structure.KeyBaseInterface, bool) {
if lru.lruMap == nil {
return nil, false
@ -118,7 +118,7 @@ func (lru *singleCache) Get(key string) (structure.KeyBaseInterface, bool) {
}
//Del 删除机制
func (lru *singleCache) Del() error {
func (lru *SingleCache) Del() error {
if lru.lruMap == nil {
return errorx.New("lru is nil")
}