map default namespace try
This commit is contained in:
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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user