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

22
cache/get.go vendored Normal file
View File

@@ -0,0 +1,22 @@
package cache
import (
"fmt"
"github.com/xujiajun/nutsdb"
)
func (c *Client) Get(bucket string, key string) ([]byte, error) {
var value []byte
if err := c.db.View(func(tx *nutsdb.Tx) error {
e, err := tx.Get(bucket, []byte(key))
if err != nil {
return fmt.Errorf("%v: %v; get: %w", bucket, key, err)
}
value = e.Value
return nil
}); err != nil {
return nil, err
}
return value, nil
}