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 }

 

posted on 2015-04-17 10:06  rojas  阅读(866)  评论(0编辑  收藏  举报