# README
persistent-cache
go-cache is an in-memory key:value
store/cache similar to memcached that issuitable for applications running on
a single machine. Its major advantage is that, being essentially a thread-safe
map[string]interface{}
with expiration times, it doesn't need to serialize
or transmit its contents over the network.
Any object can be stored, for a given duration or forever, and the cache can be safely used by multiple goroutines.
persistent-cache write cache changes to the binlog file.
Installation
go get github.com/severecloud/persistent-cache
Usage
package main
import (
"fmt"
pcache "github.com/severecloud/persistent-cache"
)
func main() {
c, err := pcache.Load(pcache.NoExpiration, 0, "test")
if err != nil {
c, err = pcache.New(pcache.NoExpiration, 0, "test")
if err != nil {
panic(err)
}
}
foo, found := c.Get("foo")
if found {
fmt.Println(foo)
}
c.SetDefault("foo", "bar")
}