BoltDB 事务流程
分析的 etcd-io/bbolt 的代码,同时基本不会改动了。 文章不会写上详细的信息,但是会留下链接供自己深入研究。
结构
首先看事务的结构体 Tx
// txid represents the internal transaction identifier.
type txid uint64
// Tx represents a read-only or read/write transaction on the database.
// Read-only transactions can be used for retrieving values for keys and creating cursors.
// Read/write transactions can create and remove buckets and create and remove keys.
type Tx struct {
writable bool
managed bool
db *DB
meta *meta
root Bucket
pages map[pgid]*page
stats TxStats
commitHandlers []func()
// WriteFlag specifies the flag for write-related methods like WriteTo().
// Tx opens the database file with the specified flag to copy the data.
WriteFlag int
}
相关文章