go-mcache
In-memory cache manager in Golang, key/value data storage with storage duration
Install
go get github.com/Sagleft/go-mcache
Usage example
Import package
import (
mcache "github.com/Sagleft/go-mcache"
)
Init cache
// Create a cache with a default lifetime of 5 minutes and delete expired caches every 10 minutes
cache := memorycache.New(5 * time.Minute, 1 * time.Minute)
Usage
// Install the cache with the key "myKey" and a lifetime of 5 minutes
cache.Set("myKey", "My value", 5 * time.Minute)
// Get the cache with the "myKey" key
i := cache.Get("myKey")