代码拉取完成,页面将自动刷新
package cache
import (
"testing"
"time"
)
var cacheObject = NewMemoryCache(10000,10000);
type cacheTest struct {
key string;
value interface{};
duration time.Duration;
slidingExpiration int;
regionName string
}
type cacheDataValue struct {
id int;
name string
}
var cacheTestValue = []cacheTest{
cacheTest{ key:"cache1",value: cacheDataValue{ id :1,name:"linux"},duration:time.Minute * 2,slidingExpiration: SlidingExpiration,regionName:"default1"},
cacheTest{ key:"cache2",value:cacheDataValue{id:2,name:"毛晓武"},duration:time.Minute * 2,slidingExpiration: SlidingExpiration,regionName:"default2"},
cacheTest{ key:"cache2",value:cacheDataValue{id:3,name:"江小流"},duration:time.Minute * 2,slidingExpiration: SlidingExpiration,regionName:"default3"},
}
func TestSet(t *testing.T){
for _,v := range cacheTestValue{
err := cacheObject.Add(v.key,v.value,v.duration);
if(err == false){
t.Errorf("key:%s value:%v duration:%v",v.key,v.value,v.duration)
}
}
}
func TestGet(t *testing.T){
for _, v := range cacheTestValue{
value,ok := cacheObject.Get(v.key);
if(!ok){
t.Errorf("key:%s value:%v duration:%v",v.key,v.value,v.duration)
}else{
value := value.(cacheDataValue);
t.Logf("id=%v name=%s",value.id,value.name)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。