golang beego cache
1 package main 2 3 import ( 4 "fmt" 5 "github.com/astaxie/beego/cache" 6 "time" 7 ) 8 9 func main() { 10 //一秒钟 11 bm, _ := cache.NewCache("memory", `{"interval":1}`) 12 13 bm.Put("astaxie", 1, 10) 14 bm.Get("astaxie") 15 fmt.Println("do get: ", bm.Get("astaxie")) 16 bm.IsExist("astaxie") 17 fmt.Println("IsExist: ", bm.IsExist("astaxie")) 18 //bm.Delete("astaxie") 19 20 //900毫秒 21 time.Sleep(time.Millisecond * 900) 22 fmt.Println("IsExist: ", bm.IsExist("astaxie")) 23 fmt.Println("time over ", bm.Get("astaxie")) 24 25 }