You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gocache/big_test.go

36 lines
722 B

2 years ago
package gocache
import (
"testing"
"time"
)
func TestBig(t *testing.T) {
2 years ago
newCache := NewBig(time.Minute * 30)
2 years ago
// 字符串
2 years ago
newCache.Set("key1", "测试Big插入数据 1")
key1, _ := newCache.Get("key1")
2 years ago
t.Logf("key1%+v", key1)
// 结构体
type name struct {
Test string `json:"test"`
}
2 years ago
newCache.Set("key2", name{"测试Big插入数据 2"})
key2, _ := newCache.Get("key2")
2 years ago
t.Logf("key2%+v", key2)
2 years ago
t.Logf("key2%+v", key2.(name))
2 years ago
2 years ago
// 缓存组件
2 years ago
newCacheCache := newCache.NewCache()
newCacheCache.GetterInterface = func() interface{} {
return name{"测试Big插入数据 3"}
2 years ago
}
2 years ago
key3 := newCacheCache.GetInterface("key3")
2 years ago
t.Logf("key3%+v", key3)
2 years ago
t.Logf("key3%+v", key3.(name))
2 years ago
2 years ago
}