func (kvs KvService) Put(ctx context.Context, name string, data []byte) error {
	keyname := CACHE_PREFIX + name
	cs := kvs.nh.GetNoOPSession(kvs.AppConfig.Cluster.Group)
	kv := &KVAction{
		Key: keyname,
		Val: data,
	}
	kvdata, err := json.Marshal(kv)
	if err != nil {
		rlog.Errorf("[PUT] Cache key: %s, error: %v", kv.Key, err)
	}
	cctx, cancel := context.WithTimeout(ctx, time.Duration(12*time.Second))
	defer cancel()
	_, err = kvs.nh.SyncPropose(cctx, cs, kvdata)
	if err == nil {
		CertCache.Set(name, &data, cache.DefaultExpiration)
	}
	return err
}
Put writes the certificate data to the specified kv.
package main
import (
	"context"
	"encoding/json"
	"golang.org/x/crypto/acme/autocert"
	"time"
	"github.com/patrickmn/go-cache"
)
var CertCache = cache.New(3600*time.Second, 90*time.Second)
func (kvs KvService) Get(ctx context.Context, name string) ([]byte, error) {
	if p, found := CertCache.Get(name); found {
		return p.([]byte), nil
	}
	keyname := CACHE_PREFIX + name
	cctx, cancel := context.WithTimeout(ctx, time.Duration(12*time.Second))
	defer cancel()
	result, err := kvs.nh.SyncRead(cctx, kvs.AppConfig.Cluster.Group, keyname)
	if err != nil {
		rlog.Errorf("SyncRead returned error %v\n", err)
		return nil, err
	}
	if len(result.([]byte)) == 0 {
		rlog.Infof("[GET] Cache miss, key: %s\n", keyname)
		return nil, autocert.ErrCacheMiss
	}
	CertCache.Set(name, result, cache.DefaultExpiration)
	return result.([]byte), nil
}