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

16
map.go
View File

@@ -1,7 +1,6 @@
package storage
import (
"errors"
"fmt"
)
@@ -30,7 +29,20 @@ func (m *Map) Close() error {
}
func (m *Map) List(ns []string, limits ...string) ([]string, error) {
return nil, errors.New("not impl")
namespace := resolveNamespace(ns)
limits = resolveLimits(limits)
keys := []string{}
if _, ok := (*m)[namespace]; !ok {
return nil, nil
}
for k := range (*m)[namespace] {
if k >= limits[0] && k <= limits[1] {
keys = append(keys, k)
}
}
return keys, nil
}
func (m *Map) Get(key string, ns ...string) ([]byte, error) {