go get -u github.com/yuseferi/gocache Usage: cache := gocache.NewCache(time.Minute * 2) // with 2 minutes interval cleaning expired items cache.Set("key", "value", time.Minute) // set cache value, found := cache.Get("key") // retrive cache data cache.Delete("key") // delete...
Gocache 项目诞生了:https://github.com/eko/gocache。 存储接口 首先,当你准备缓存一些数据时,你必须选择缓存的存储方式:简单的直接放进内存?使用 Redis 或者 Memcache?或者其它某种形式的存储。 目前,Gocache 已经实现了以下存储方案: Bigcache: 简单的内存存储。 Ristretto: 由 DGraph 提供的内存存储。 Memcache:...
import ( "log" "github.com/away-team/go-cache/src/cache" "github.com/away-team/go-cache/src/storage/memory" rstorage "github.com/away-team/go-cache/src/storage/redis" ) ... // memory storage setup defaultExpiration := time.Second * 3600 //how long before items expire by default cl...
go-cache,github 5.8k star 单机本地缓存的代表golang项目。 patrickmn/go-cache: An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications. (github.com)github.com/patrickmn/go-cache bigcache, github 5.4k star 以高效、高性能为推广点。
go get github.com/bbdshow/gocache 请查看 example 目录 Notice 选择sync.Map 的实现方式需要 golang 1.11^ master 分支为开发分支,最新版本 FAQ 选择sync.Map 实现 利用sync.map 达到读取性能相对更高,sync.Map 并不太适应大量写入的缓存操作, 且因为计数使用了 LoadOrStrore 对 key 计数。 sync.Map 在内存...
go get github.com/patrickmn/go-cacheUsageimport ( "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) // ...
A Go toolchain cache plugin backed by S3. Contribute to tailscale/go-cache-plugin development by creating an account on GitHub.
Cache benchmark for Golang. Contribute to vmihailenco/go-cache-benchmark development by creating an account on GitHub.
package main import ( "time" "fmt" cache "github.com/morkid/gocache-redis/v8" "github.com/go-redis/redis/v8" ) func main() { client := redis.NewClient(&redis.Options{ Addr: "localhost:6379", Password: "", DB: 0, }) config := cache.RedisCacheConfig{ Client: client, ExpiresIn:...
A Go toolchain cache plugin backed by S3. Contribute to tailscale/go-cache-plugin development by creating an account on GitHub.