本站源代码
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.

68 lines
922B

  1. package driver
  2. import (
  3. "errors"
  4. )
  5. var (
  6. ErrTxSupport = errors.New("transaction is not supported")
  7. )
  8. type IDB interface {
  9. Close() error
  10. Get(key []byte) ([]byte, error)
  11. Put(key []byte, value []byte) error
  12. Delete(key []byte) error
  13. NewIterator() IIterator
  14. NewWriteBatch() IWriteBatch
  15. NewSnapshot() (ISnapshot, error)
  16. Begin() (Tx, error)
  17. }
  18. type ISnapshot interface {
  19. Get(key []byte) ([]byte, error)
  20. NewIterator() IIterator
  21. Close()
  22. }
  23. type IIterator interface {
  24. Close() error
  25. First()
  26. Last()
  27. Seek(key []byte)
  28. Next()
  29. Prev()
  30. Valid() bool
  31. Key() []byte
  32. Value() []byte
  33. }
  34. type IWriteBatch interface {
  35. Put(key []byte, value []byte)
  36. Delete(key []byte)
  37. Commit() error
  38. Rollback() error
  39. }
  40. type Tx interface {
  41. Get(key []byte) ([]byte, error)
  42. Put(key []byte, value []byte) error
  43. Delete(key []byte) error
  44. NewIterator() IIterator
  45. NewWriteBatch() IWriteBatch
  46. Commit() error
  47. Rollback() error
  48. }
上海开阖软件有限公司 沪ICP备12045867号-1