wheat-cache/pkg/lru/lru_test.go

24 lines
506 B
Go
Raw Normal View History

2021-09-27 11:29:47 +08:00
package lru
import (
2021-10-04 20:32:20 +08:00
"fmt"
2021-09-27 11:29:47 +08:00
"gitee.com/timedb/wheatCache/pkg/structure/stringx"
2021-10-04 11:21:55 +08:00
"github.com/stretchr/testify/require"
2021-09-27 11:29:47 +08:00
"testing"
)
func TestNewLRUCache(t *testing.T) {
cache := NewLRUCache()
v1 := stringx.NewStringSingle()
v2 := stringx.NewStringSingle()
v3 := stringx.NewStringSingle()
cache.Add("1", v1)
cache.Add("2", v2)
cache.Add("3", v3)
cache.Add("1", v1)
2021-10-04 20:32:20 +08:00
fmt.Println(cache.nowSize)
2021-09-27 11:29:47 +08:00
cache.Del()
2021-10-04 20:32:20 +08:00
fmt.Println(cache.nowSize)
2021-10-04 11:21:55 +08:00
_, isTrue := cache.Get("1")
require.Equal(t, isTrue, true)
2021-09-27 11:29:47 +08:00
}