map default namespace try
parent
f807cc71b2
commit
283c2dffd2
|
|
@ -94,24 +94,6 @@ func TestImplementations(t *testing.T) {
|
||||||
cases = append(cases, leveldb)
|
cases = append(cases, leveldb)
|
||||||
}
|
}
|
||||||
|
|
||||||
riakLN, err := net.Listen("tcp", "localhost:8087")
|
|
||||||
if err == nil {
|
|
||||||
defer riakLN.Close()
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
conn, err := riakLN.Accept()
|
|
||||||
if err == nil {
|
|
||||||
conn.Close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
if riak, err := NewRiak("localhost:8087"); err != nil {
|
|
||||||
t.Logf("cannot make riak: %v", err)
|
|
||||||
} else {
|
|
||||||
cases = append(cases, riak)
|
|
||||||
}
|
|
||||||
|
|
||||||
mongoLN, err := net.Listen("tcp", "localhost:27017")
|
mongoLN, err := net.Listen("tcp", "localhost:27017")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer mongoLN.Close()
|
defer mongoLN.Close()
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,13 @@ func (ldb *LevelDB) Get(key string, ns ...string) ([]byte, error) {
|
||||||
|
|
||||||
func (ldb *LevelDB) Set(key string, value []byte, ns ...string) error {
|
func (ldb *LevelDB) Set(key string, value []byte, ns ...string) error {
|
||||||
namespace := resolveNamespace(ns)
|
namespace := resolveNamespace(ns)
|
||||||
|
key = path.Join(namespace, key)
|
||||||
batch := &leveldb.Batch{}
|
batch := &leveldb.Batch{}
|
||||||
batch.Put([]byte(path.Join(namespace, key)), value)
|
if value != nil {
|
||||||
|
batch.Put([]byte(key), value)
|
||||||
|
} else {
|
||||||
|
batch.Delete([]byte(key))
|
||||||
|
}
|
||||||
return ldb.db.Write(batch, nil)
|
return ldb.db.Write(batch, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,11 @@ func (m *Map) List(ns []string, limits ...string) ([]string, error) {
|
||||||
limits = resolveLimits(limits)
|
limits = resolveLimits(limits)
|
||||||
|
|
||||||
keys := []string{}
|
keys := []string{}
|
||||||
if _, ok := (*m)[namespace]; !ok {
|
n, _ := (*m)[DefaultNamespace]
|
||||||
return nil, nil
|
if v, ok := (*m)[namespace]; ok {
|
||||||
|
n = v
|
||||||
}
|
}
|
||||||
for k := range (*m)[namespace] {
|
for k := range n {
|
||||||
if k >= limits[0] && k <= limits[1] {
|
if k >= limits[0] && k <= limits[1] {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue