MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / Delete

Method Delete

batch.go:98–118  ·  view source on GitHub ↗

func (tx *Tx) Delete(bucket string, key []byte) error

(bucket string, key []byte)

Source from the content-addressed store, hash-verified

96
97// func (tx *Tx) Delete(bucket string, key []byte) error
98func (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
120func (wb *WriteBatch) commit() error {
121 if err := wb.Error(); err != nil {

Callers 2

TestBatchWriteFunction · 0.95
mainFunction · 0.95

Calls 5

commitMethod · 0.95
lockMethod · 0.80
unlockMethod · 0.80
checkSizeMethod · 0.80
DeleteMethod · 0.65

Tested by 1

TestBatchWriteFunction · 0.76