短小精悍的gocache是一个线程安全的map
example
使用示例
package main
import (
"fmt"
"github.com/patrickmn/go-cache"
"time"
)
func main() {
// Create a cache with a default expiration time of 5 minutes, and which
// purges expired items every 10 minutes
c := cache.New(5*time.Minute, 10*time.Minute)
// Set the value of the key "foo" to "bar", with the default expiration time
c.Add("foo","bar",cache.DefaultExpiration)
if v,found:=c.Get("foo"); found{
fmt.Println(v)
}
//fmt.Println(c)
}
特点
interface{}