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

@@ -3,6 +3,7 @@ package storage
import (
"errors"
"fmt"
"local/storage/resolve"
"time"
"github.com/gomodule/redigo/redis"
@@ -33,9 +34,9 @@ func (m *Redis) Close() error {
}
func (m *Redis) List(ns []string, limits ...string) ([]string, error) {
limits = resolveLimits(limits)
limits[0] = resolveNamespace(append(ns, limits[0]))
limits[1] = resolveNamespace(append(ns, limits[1]))
limits = resolve.Limits(limits)
limits[0] = resolve.Namespace(append(ns, limits[0]))
limits[1] = resolve.Namespace(append(ns, limits[1]))
resp, err := m.client.Do("KEYS", "*")
if err != nil {
@@ -65,7 +66,7 @@ func (m *Redis) List(ns []string, limits ...string) ([]string, error) {
}
func (m *Redis) Get(key string, ns ...string) ([]byte, error) {
key = resolveNamespace(append(ns, key))
key = resolve.Namespace(append(ns, key))
resp, err := m.client.Do("GET", key)
if err != nil {
return nil, err
@@ -81,7 +82,7 @@ func (m *Redis) Get(key string, ns ...string) ([]byte, error) {
}
func (m *Redis) Set(key string, value []byte, ns ...string) error {
namespace := resolveNamespace(append(ns, key))
namespace := resolve.Namespace(append(ns, key))
_, err := m.client.Do("SET", namespace, value)
return err
}