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

28 lines
425B

  1. package goleveldb
  2. import (
  3. "github.com/syndtr/goleveldb/leveldb"
  4. )
  5. type WriteBatch struct {
  6. db *DB
  7. wbatch *leveldb.Batch
  8. }
  9. func (w *WriteBatch) Put(key, value []byte) {
  10. w.wbatch.Put(key, value)
  11. }
  12. func (w *WriteBatch) Delete(key []byte) {
  13. w.wbatch.Delete(key)
  14. }
  15. func (w *WriteBatch) Commit() error {
  16. return w.db.db.Write(w.wbatch, nil)
  17. }
  18. func (w *WriteBatch) Rollback() error {
  19. w.wbatch.Reset()
  20. return nil
  21. }
上海开阖软件有限公司 沪ICP备12045867号-1