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.

48 lines
820 B

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