File: batch.go

package info (click to toggle)
golang-github-lunny-nodb 0.0~git20160621.0.fc1ef06-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 424 kB
  • sloc: python: 259; sh: 50; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package goleveldb

import (
	"github.com/syndtr/goleveldb/leveldb"
)

type WriteBatch struct {
	db     *DB
	wbatch *leveldb.Batch
}

func (w *WriteBatch) Put(key, value []byte) {
	w.wbatch.Put(key, value)
}

func (w *WriteBatch) Delete(key []byte) {
	w.wbatch.Delete(key)
}

func (w *WriteBatch) Commit() error {
	return w.db.db.Write(w.wbatch, nil)
}

func (w *WriteBatch) Rollback() error {
	w.wbatch.Reset()
	return nil
}