move resolve into package

This commit is contained in:
Bel LaPointe
2021-02-21 12:39:15 -06:00
parent ff8b908ee7
commit 7f2d451ca4
15 changed files with 205 additions and 175 deletions

View File

@@ -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
}