func (tx *Tx) Delete(bucket string, key []byte) error
(bucket string, key []byte)
| 96 | |
| 97 | // func (tx *Tx) Delete(bucket string, key []byte) error |
| 98 | func (wb *WriteBatch) Delete(bucket string, key []byte) error { |
| 99 | wb.Lock() |
| 100 | defer wb.Unlock() |
| 101 | |
| 102 | wb.tx.lock() |
| 103 | err := wb.tx.Delete(bucket, key) |
| 104 | if err != nil { |
| 105 | wb.tx.unlock() |
| 106 | return err |
| 107 | } |
| 108 | |
| 109 | // Check if batch is full (checkSize returns ErrTxnTooBig when full) |
| 110 | if err := wb.tx.checkSize(); err != nil { |
| 111 | // Batch is full, commit now |
| 112 | wb.tx.unlock() |
| 113 | return wb.commit() |
| 114 | } |
| 115 | // Batch not full, write is pending, unlock and return |
| 116 | wb.tx.unlock() |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | func (wb *WriteBatch) commit() error { |
| 121 | if err := wb.Error(); err != nil { |