An advanced, user-persisted map with caching capabilities - under dev
License: MIT License
Go 100.00%
cachemap's Introduction
cachemap
A memory-friendly map with a user-defined persistence store.
Usage
go get github.com/steakknife/cachemap
import"github.com/steakknife/cachemap"typeStoresomething// define all methods of cachemap.Persistents:=Store{}
m:=NewCacheMap(&s)
err:=m.Add("key", "value", 3, 5)
v, err:=m.Get("key") // v = "value"err=m.Delete("key")
err=m.Add("big", somethingbig, 3, 1024*1024*1024)
err=m.Evict("big") // force something big out of RAMm.DropCaches() // drop all cached itemss2:=Store{}
m2:=NewLazyCacheMap(&s2) // faster adds, but a goroutine in the background Evict()s things