move resolve into package
This commit is contained in:
11
leveldb.go
11
leveldb.go
@@ -1,6 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"local/storage/resolve"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -39,7 +40,7 @@ func NewLevelDB(path string) (*LevelDB, error) {
|
||||
}
|
||||
|
||||
func (ldb *LevelDB) Get(key string, ns ...string) ([]byte, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
snapshot, err := ldb.db.GetSnapshot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -57,7 +58,7 @@ func (ldb *LevelDB) Get(key string, ns ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (ldb *LevelDB) Set(key string, value []byte, ns ...string) error {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
key = path.Join(namespace, key)
|
||||
batch := &leveldb.Batch{}
|
||||
if value != nil {
|
||||
@@ -73,8 +74,8 @@ func (ldb *LevelDB) Close() error {
|
||||
}
|
||||
|
||||
func (ldb *LevelDB) List(ns []string, limits ...string) ([]string, error) {
|
||||
namespace := path.Join(resolveNamespace(ns))
|
||||
limits = resolveLimits(limits)
|
||||
namespace := path.Join(resolve.Namespace(ns))
|
||||
limits = resolve.Limits(limits)
|
||||
it, next := ldb.getIterator(namespace, limits)
|
||||
defer it.Release()
|
||||
keys := ldb.useIterator(it, next, namespace, limits)
|
||||
@@ -99,7 +100,7 @@ func (ldb *LevelDB) getIterator(namespace string, limits []string) (iterator.Ite
|
||||
}
|
||||
|
||||
func (ldb *LevelDB) useIterator(it iterator.Iterator, next func() bool, namespace string, limits []string) []string {
|
||||
limits = resolveLimits(limits)
|
||||
limits = resolve.Limits(limits)
|
||||
n, _ := strconv.Atoi(limits[2])
|
||||
m := 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user