diff --git a/leveldb/db.go b/leveldb/db.go index 48a78dc..b9ed2df 100644 --- a/leveldb/db.go +++ b/leveldb/db.go @@ -8,6 +8,7 @@ package leveldb import ( "container/list" + "context" "fmt" "io" "os" @@ -871,6 +872,16 @@ func (db *DB) has(auxm *memdb.DB, auxt tFiles, key []byte, seq uint64, ro *opt.R func (db *DB) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error) { fmt.Println("GET BABY key", string(key)) + val2, err := db.rdb.Get(context.Background(), string(key)).Result() + if err == redis.Nil { + return nil, nil + } else if err != nil { + return nil, err + } + return []byte(val2), nil + + //fmt.Println("GET BABY key", string(key)) + err = db.ok() if err != nil { return @@ -886,6 +897,13 @@ func (db *DB) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error) { // It is safe to modify the contents of the argument after Has returns. func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error) { fmt.Println("HAS BABY key", string(key)) + _, err = db.rdb.Get(context.Background(), string(key)).Result() + if err == redis.Nil { + return false, nil + } else if err != nil { + return false, err + } + return true, nil err = db.ok() if err != nil { diff --git a/leveldb/db_write.go b/leveldb/db_write.go index e70796e..b50ff20 100644 --- a/leveldb/db_write.go +++ b/leveldb/db_write.go @@ -7,6 +7,7 @@ package leveldb import ( + "context" "fmt" "sync/atomic" "time" @@ -335,9 +336,11 @@ func (db *DB) Write(batch *Batch, wo *opt.WriteOptions) error { func (db *DB) putRec(kt keyType, key, value []byte, wo *opt.WriteOptions) error { //fmt.Println("leveldb putRec", kt.String(), string(key), string(value)) + db.rdb.Set(context.Background(), string(key), value, 0) s := fmt.Sprintf("leveldb putRec keyType %v key %v value %v.\n", kt.String(), string(key), string(value)) fmt.Println(s) + return nil if err := db.ok(); err != nil { return err