wheat-cache/pkg/lru/lru_test.go

24 lines
506 B
Go

package lru
import (
"fmt"
"gitee.com/timedb/wheatCache/pkg/structure/stringx"
"github.com/stretchr/testify/require"
"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)
fmt.Println(cache.nowSize)
cache.Del()
fmt.Println(cache.nowSize)
_, isTrue := cache.Get("1")
require.Equal(t, isTrue, true)
}