handle error

This commit is contained in:
maskpp 2024-08-30 18:50:38 +08:00
parent f671be40b4
commit 0cc283e747

View file

@ -523,17 +523,21 @@ type batch struct {
// Put inserts the given value into the batch for later committing. // Put inserts the given value into the batch for later committing.
func (b *batch) Put(key, value []byte) error { func (b *batch) Put(key, value []byte) error {
err := b.b.Set(key, value, nil) if err := b.b.Set(key, value, nil); err != nil {
b.size += len(key) + len(value)
return err return err
} }
b.size += len(key) + len(value)
return nil
}
// Delete inserts the key removal into the batch for later committing. // Delete inserts the key removal into the batch for later committing.
func (b *batch) Delete(key []byte) error { func (b *batch) Delete(key []byte) error {
err := b.b.Delete(key, nil) if err := b.b.Delete(key, nil); err != nil {
b.size += len(key)
return err return err
} }
b.size += len(key)
return nil
}
// ValueSize retrieves the amount of data queued up for writing. // ValueSize retrieves the amount of data queued up for writing.
func (b *batch) ValueSize() int { func (b *batch) ValueSize() int {