map default namespace try
This commit is contained in:
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
cli/main.go
Normal file → Executable file
0
cli/main.go
Normal file → Executable file
18
db_test.go
Normal file → Executable file
18
db_test.go
Normal file → Executable file
@@ -94,24 +94,6 @@ func TestImplementations(t *testing.T) {
|
||||
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")
|
||||
if err == nil {
|
||||
defer mongoLN.Close()
|
||||
|
||||
0
dynomite.go
Normal file → Executable file
0
dynomite.go
Normal file → Executable file
7
leveldb.go
Normal file → Executable file
7
leveldb.go
Normal file → Executable file
@@ -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 {
|
||||
namespace := resolveNamespace(ns)
|
||||
key = path.Join(namespace, key)
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
7
map.go
Normal file → Executable file
7
map.go
Normal file → Executable file
@@ -33,10 +33,11 @@ func (m *Map) List(ns []string, limits ...string) ([]string, error) {
|
||||
limits = resolveLimits(limits)
|
||||
|
||||
keys := []string{}
|
||||
if _, ok := (*m)[namespace]; !ok {
|
||||
return nil, nil
|
||||
n, _ := (*m)[DefaultNamespace]
|
||||
if v, ok := (*m)[namespace]; ok {
|
||||
n = v
|
||||
}
|
||||
for k := range (*m)[namespace] {
|
||||
for k := range n {
|
||||
if k >= limits[0] && k <= limits[1] {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
0
memcache.go
Normal file → Executable file
0
memcache.go
Normal file → Executable file
0
memcachecluster.go
Normal file → Executable file
0
memcachecluster.go
Normal file → Executable file
Reference in New Issue
Block a user