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