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 }

 

相关文章:

  • 2022-03-08
  • 2022-12-23
  • 2021-08-10
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-02-01
猜你喜欢
  • 2021-08-03
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2019-01-19
  • 2022-02-22
  • 2022-12-23
相关资源
相似解决方案