move resolve into package
This commit is contained in:
14
bolt.go
14
bolt.go
@@ -1,6 +1,10 @@
|
||||
package storage
|
||||
|
||||
import "github.com/boltdb/bolt"
|
||||
import (
|
||||
"local/storage/resolve"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
)
|
||||
|
||||
type Bolt struct {
|
||||
db *bolt.DB
|
||||
@@ -14,8 +18,8 @@ func NewBolt(path string) (*Bolt, error) {
|
||||
}
|
||||
|
||||
func (b *Bolt) List(ns []string, limits ...string) ([]string, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
limits = resolveLimits(limits)
|
||||
namespace := resolve.Namespace(ns)
|
||||
limits = resolve.Limits(limits)
|
||||
found := []string{}
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket([]byte(namespace))
|
||||
@@ -33,7 +37,7 @@ func (b *Bolt) List(ns []string, limits ...string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (b *Bolt) Get(key string, ns ...string) ([]byte, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
var result []byte
|
||||
err := b.db.View(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket([]byte(namespace))
|
||||
@@ -50,7 +54,7 @@ func (b *Bolt) Get(key string, ns ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (b *Bolt) Set(key string, value []byte, ns ...string) error {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
return b.db.Update(func(tx *bolt.Tx) error {
|
||||
bkt, err := tx.CreateBucketIfNotExists([]byte(namespace))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user