mirror of https://github.com/ledisdb/ledisdb.git
rpl optimize
This commit is contained in:
parent
9256808dc5
commit
1ca74b404a
|
@ -14,6 +14,8 @@ type WriteBatch struct {
|
||||||
putNum int64
|
putNum int64
|
||||||
deleteNum int64
|
deleteNum int64
|
||||||
db *DB
|
db *DB
|
||||||
|
|
||||||
|
data *BatchData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wb *WriteBatch) Close() {
|
func (wb *WriteBatch) Close() {
|
||||||
|
@ -60,13 +62,12 @@ func (wb *WriteBatch) Rollback() error {
|
||||||
// the data will be undefined after commit or rollback
|
// the data will be undefined after commit or rollback
|
||||||
func (wb *WriteBatch) BatchData() *BatchData {
|
func (wb *WriteBatch) BatchData() *BatchData {
|
||||||
data := wb.wb.Data()
|
data := wb.wb.Data()
|
||||||
d, err := NewBatchData(data)
|
if wb.data == nil {
|
||||||
if err != nil {
|
wb.data = new(BatchData)
|
||||||
//can not enter this
|
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d
|
wb.data.Load(data)
|
||||||
|
return wb.data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wb *WriteBatch) Data() []byte {
|
func (wb *WriteBatch) Data() []byte {
|
||||||
|
|
Loading…
Reference in New Issue