move resolve into package
This commit is contained in:
9
map.go
9
map.go
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"local/storage/resolve"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -40,8 +41,8 @@ func (m *Map) Close() error {
|
||||
func (m *Map) List(ns []string, limits ...string) ([]string, error) {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
namespace := resolveNamespace(ns)
|
||||
limits = resolveLimits(limits)
|
||||
namespace := resolve.Namespace(ns)
|
||||
limits = resolve.Limits(limits)
|
||||
|
||||
keys := []string{}
|
||||
if _, ok := m.m[namespace]; !ok {
|
||||
@@ -59,7 +60,7 @@ func (m *Map) List(ns []string, limits ...string) ([]string, error) {
|
||||
func (m *Map) Get(key string, ns ...string) ([]byte, error) {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
if _, ok := m.m[namespace]; !ok {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
@@ -72,7 +73,7 @@ func (m *Map) Get(key string, ns ...string) ([]byte, error) {
|
||||
func (m *Map) Set(key string, value []byte, ns ...string) error {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
if value == nil {
|
||||
if _, ok := m.m[namespace]; !ok {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user