go-cache Go 语言的缓存框架开源项目

我要开发同款
匿名用户2012年04月09日
31阅读
所属分类Google Go、程序开发、缓存系统
授权协议MIT

作品详情

go-cache是Go语言实现的一个内存中的缓存框架,实现Key-Value的序列存储。

示例代码:

import "github.com/pmylund/go-cache"// Create a cache with a default expiration time of 5 minutes, and which// purges expired items every 30 secondsc := cache.New(5*time.Minute, 30*time.Second)// Set the value of the key "foo" to "bar", with the default expiration timec.Set("foo", "bar", 0)// Set the value of the key "baz" to "yes", with no expiration time// (the item won't be removed until it is re-set, or removed using// c.Delete("baz")c.Set("baz", "yes", -1)// Get the string associated with the key "foo" from the cachefoo, found := c.Get("foo")if found {        fmt.Println(foo)}
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论