【问题标题】:Batching Operations in BoltdbBoltdb 中的批处理操作
【发布时间】:2015-06-18 07:17:34
【问题描述】:

目前正在使用 db.Update() 更新 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
})

如何使用 goroutine 使用 db.Batch() 操作?

【问题讨论】:

    标签: go embedded-database batching boltdb


    【解决方案1】:

    只需从您的 goroutine 中调用 db.Batch() 即可。创建 Batch() 就是为了以这种方式使用。 documentation中有一个例子。

    【讨论】:

    • 谢谢!我看到了,它使用的是服务器。我需要一个更简单的例子,因为我是初学者。
    猜你喜欢
    • 1970-01-01
    • 2020-05-08
    • 2018-05-19
    • 1970-01-01
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 2019-12-13
    相关资源
    最近更新 更多