Originally developed as an implementation of the Cache Interface for Go acme/autocert in chroot
environments. However it can be used for anything. The key/value store is realized in a single Json file opened on startup, therefore available even if caller invokes chroot
.
import (
"github.com/tenox7/tkvs"
"golang.org/x/crypto/acme/autocert"
)
acm := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("www.mysite.com"),
Cache: tkvs.New("/var/cache/acme-store.json", autocert.ErrCacheMiss),
}
syscall.Chroot(dir)
import "github.com/tenox7/tkvs"
kvs := tkvs.New("/var/cache/mystore.json", errors.New("key not found"))
kvs.Put(ctx, "myKey", []byte("myValue"))
kvs.Get(ctx, "myKey")
kvs.Delete(ctx, "myKey")