Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batching Operations in Boltdb

Currently using db.Update() to update the key-value in boltdb.

err := db.Update(func(tx *bolt.Tx) error {

    b, err := tx.CreateBucket([]byte("widgets"))
    if err != nil {
        return err
    }
    if err := b.Put([]byte("foo"), []byte("bar")); err != nil {
        return err
    }
    return nil
})

How to use db.Batch() operations using go routines?

like image 780
Raunak Dugar Avatar asked Jun 28 '26 08:06

Raunak Dugar


1 Answers

Just call db.Batch() from your goroutines. Batch() was created to be used this way. There is an example in documentation.

like image 176
Marko Kevac Avatar answered Jul 01 '26 05:07

Marko Kevac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!