Implement list and fix test
This commit is contained in:
14
cache.go
14
cache.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user