mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-15 19:26:42 +08:00
40 lines
659 B
Go
40 lines
659 B
Go
|
package leveldb
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
func (store *LevelDBStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
|
||
|
|
||
|
err = store.db.Put(key, value, nil)
|
||
|
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("kv put: %v", err)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (store *LevelDBStore) KvGet(ctx context.Context, key []byte) (value []byte, err error) {
|
||
|
|
||
|
value, err = store.db.Get(key, nil)
|
||
|
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("kv get: %v", err)
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (store *LevelDBStore) KvDelete(ctx context.Context, key []byte) (err error) {
|
||
|
|
||
|
err = store.db.Delete(key, nil)
|
||
|
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("kv delete: %v", err)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|