You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
801 B

  1. // +build rocksdb
  2. package rocksdb
  3. import (
  4. "context"
  5. "fmt"
  6. "github.com/chrislusf/seaweedfs/weed/filer"
  7. )
  8. func (store *RocksDBStore) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
  9. err = store.db.Put(store.wo, key, value)
  10. if err != nil {
  11. return fmt.Errorf("kv put: %v", err)
  12. }
  13. return nil
  14. }
  15. func (store *RocksDBStore) KvGet(ctx context.Context, key []byte) (value []byte, err error) {
  16. value, err = store.db.GetBytes(store.ro, key)
  17. if value == nil {
  18. return nil, filer.ErrKvNotFound
  19. }
  20. if err != nil {
  21. return nil, fmt.Errorf("kv get: %v", err)
  22. }
  23. return
  24. }
  25. func (store *RocksDBStore) KvDelete(ctx context.Context, key []byte) (err error) {
  26. err = store.db.Delete(store.wo, key)
  27. if err != nil {
  28. return fmt.Errorf("kv delete: %v", err)
  29. }
  30. return nil
  31. }