Batching operations in Boltdb

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

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 with go routines?

+3


source to share


1 answer


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



+2


source







All Articles