Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
maurodelazeri committed Jan 6, 2023
1 parent 2fe3fc9 commit 2e052e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions leveldb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package leveldb

import (
"container/list"
"context"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions leveldb/db_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package leveldb

import (
"context"
"fmt"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2e052e6

Please sign in to comment.