}
//获取Value 及是否有效
-func (s *tmplKV) Get(key interface{}) (isLive bool,value interface{}){
+func (s *tmplKV) Get(key interface{}) (value interface{},isLive bool){
tmp, ok := s.kvt_map.Load(key)
item,_ := tmp.(tmplKV_item)
return
}
+//获取Value 及是否有效
+func (s *tmplKV) GetV(key interface{}) (value interface{}){
+ tmp, ok := s.kvt_map.Load(key)
+
+ item,_ := tmp.(tmplKV_item)
+ value = item.kv
+
+ isLive := ok && item.kt < 0 || s.now <= item.kt
+ if !isLive && ok {
+ value = nil
+ s.kvt_map.Delete(key)
+ }
+ return
+}
+
//检查Key Value是否对应及有效
func (s *tmplKV) Check(key,value interface{}) bool {
ok,v := s.Get(key)
s.Set("a",`b`,-1)
if !s.Check("a",`b`) {t.Error(`no match2`)}
time.Sleep(time.Second*time.Duration(1))
- if !s.Check("a",`b`) {t.Error(`no TO1`)}
+ if v,ok := s.Get("a");!ok {
+ t.Error(`no TO1`)
+ }else if vv,ok := v.(string);!ok{
+ t.Error(`no string`)
+ }
+ if v,ok := s.GetV("a").(string);!ok || v != `a` {t.Error(`no 2`)}
}