2022-07-29 07:17:28 +00:00
|
|
|
//go:build rocksdb
|
2021-01-03 07:32:58 +00:00
|
|
|
// +build rocksdb
|
|
|
|
|
|
|
|
package rocksdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
2021-01-03 07:32:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (store *RocksDBStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
|
|
|
|
|
2021-01-04 13:21:46 +00:00
|
|
|
err = store.db.Put(store.wo, key, value)
|
2021-01-03 07:32:58 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("kv put: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (store *RocksDBStore) KvGet(ctx context.Context, key []byte) (value []byte, err error) {
|
|
|
|
|
2021-01-04 13:21:46 +00:00
|
|
|
value, err = store.db.GetBytes(store.ro, key)
|
2021-01-03 07:32:58 +00:00
|
|
|
|
|
|
|
if value == nil {
|
|
|
|
return nil, filer.ErrKvNotFound
|
|
|
|
}
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("kv get: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (store *RocksDBStore) KvDelete(ctx context.Context, key []byte) (err error) {
|
|
|
|
|
2021-01-04 13:21:46 +00:00
|
|
|
err = store.db.Delete(store.wo, key)
|
2021-01-03 07:32:58 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("kv delete: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|