move resolve into package
This commit is contained in:
9
cache.go
9
cache.go
@@ -1,6 +1,7 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"local/storage/resolve"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -27,8 +28,8 @@ func NewCache(path ...string) (*Cache, error) {
|
||||
}
|
||||
|
||||
func (c *Cache) List(ns []string, limits ...string) ([]string, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
limits = resolveLimits(limits)
|
||||
namespace := resolve.Namespace(ns)
|
||||
limits = resolve.Limits(limits)
|
||||
limits[0] = path.Join(namespace, limits[0])
|
||||
limits[1] = path.Join(namespace, limits[1])
|
||||
m := c.db.Items()
|
||||
@@ -42,7 +43,7 @@ func (c *Cache) List(ns []string, limits ...string) ([]string, error) {
|
||||
}
|
||||
|
||||
func (c *Cache) Get(key string, ns ...string) ([]byte, error) {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
v, ok := c.db.Get(path.Join(namespace, key))
|
||||
if !ok {
|
||||
return nil, ErrNotFound
|
||||
@@ -55,7 +56,7 @@ func (c *Cache) Get(key string, ns ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (c *Cache) Set(key string, value []byte, ns ...string) error {
|
||||
namespace := resolveNamespace(ns)
|
||||
namespace := resolve.Namespace(ns)
|
||||
c.db.Set(path.Join(namespace, key), value, 0)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user