Implement list and fix test

This commit is contained in:
bel
2019-06-21 17:57:00 -06:00
parent ade973d19d
commit 52479ed8a0
12 changed files with 161 additions and 29 deletions

View File

@@ -1,7 +1,6 @@
package storage
import (
"errors"
"os"
"path"
"time"
@@ -27,7 +26,18 @@ func NewCache(path ...string) (*Cache, error) {
}
func (c *Cache) List(ns []string, limits ...string) ([]string, error) {
return nil, errors.New("not impl")
namespace := resolveNamespace(ns)
limits = resolveLimits(limits)
limits[0] = path.Join(namespace, limits[0])
limits[1] = path.Join(namespace, limits[1])
m := c.db.Items()
keys := []string{}
for k := range m {
if k >= limits[0] && k <= limits[1] {
keys = append(keys, k)
}
}
return keys, nil
}
func (c *Cache) Get(key string, ns ...string) ([]byte, error) {