initial code (#6)

* initial code commit
This commit is contained in:
l3uddz
2021-02-14 16:18:26 +00:00
committed by GitHub
parent 3f55336fbd
commit ce3807b819
53 changed files with 3694 additions and 0 deletions

16
cache/put.go vendored Normal file
View File

@@ -0,0 +1,16 @@
package cache
import (
"fmt"
"github.com/xujiajun/nutsdb"
"time"
)
func (c *Client) Put(bucket string, key string, val []byte, ttl time.Duration) error {
if err := c.db.Update(func(tx *nutsdb.Tx) error {
return tx.Put(bucket, []byte(key), val, uint32(ttl.Seconds()))
}); err != nil {
return fmt.Errorf("%v: %v; put: %w", bucket, key, err)
}
return nil
}