map default namespace try

master
Bel LaPointe 2019-11-12 13:38:20 -07:00
parent f807cc71b2
commit 283c2dffd2
17 changed files with 10 additions and 22 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
bolt.go Normal file → Executable file
View File

0
cache.go Normal file → Executable file
View File

0
cli/: Executable file
View File

0
cli/main.go Normal file → Executable file
View File

0
db.go Normal file → Executable file
View File

18
db_test.go Normal file → Executable file
View 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
View File

0
errors.go Normal file → Executable file
View File

7
leveldb.go Normal file → Executable file
View 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
View 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
View File

0
memcachecluster.go Normal file → Executable file
View File

0
minio.go Normal file → Executable file
View File

0
mongo.go Normal file → Executable file
View File

0
redis.go Normal file → Executable file
View File

0
type.go Normal file → Executable file
View File