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.

46 lines
848 B

  1. package leveldb
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/chrislusf/seaweedfs/weed/filer"
  6. "github.com/syndtr/goleveldb/leveldb"
  7. )
  8. func (store *LevelDB3Store) KvPut(ctx context.Context, key []byte, value []byte) (err error) {
  9. err = store.dbs[DEFAULT].Put(key, value, nil)
  10. if err != nil {
  11. return fmt.Errorf("kv put: %v", err)
  12. }
  13. return nil
  14. }
  15. func (store *LevelDB3Store) KvGet(ctx context.Context, key []byte) (value []byte, err error) {
  16. value, err = store.dbs[DEFAULT].Get(key, nil)
  17. if err == leveldb.ErrNotFound {
  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 *LevelDB3Store) KvDelete(ctx context.Context, key []byte) (err error) {
  26. err = store.dbs[DEFAULT].Delete(key, nil)
  27. if err != nil {
  28. return fmt.Errorf("kv delete: %v", err)
  29. }
  30. return nil
  31. }