+2
日增长
9,832
stars
777
forks
115
watchers
972
prs
352
issues
25
releases
README
bbolt
=====
bbolt is a fork of [Ben Johnson's][gh_ben] [Bolt][bolt] key/value
store. The purpose of this fork is to provide the Go community with an active
maintenance and development target for Bolt; the goal is improved reliability
and stability. bbolt includes bug fixes, performance enhancements, and features
not found in Bolt while preserving backwards compatibility with the Bolt API.
Bolt is a pure Go key/value store inspired by [Howard Chu's][hyc_symas]
[LMDB project][lmdb]. The goal of the project is to provide a simple,
fast, and reliable database for projects that don't require a full database
server such as Postgres or MySQL.
Since Bolt is meant to be used as such a low-level piece of functionality,
simplicity is key. The API will be small and only focus on getting values
and setting values. That's it.
[gh_ben]: https://github.com/benbjohnson
[bolt]: https://github.com/boltdb/bolt
[hyc_symas]: https://twitter.com/hyc_symas
[lmdb]: https://www.symas.com/symas-embedded-database-lmdb
Project Status
Bolt is stable, the API is fixed, and the file format is fixed. Full unit
test coverage and randomized black box testing are used to ensure database
consistency and thread safety. Bolt is currently used in high-load production
environments serving databases as large as 1TB. Many companies such as
Shopify and Heroku use Bolt-backed services every day.
Project versioning
bbolt uses semantic versioning.
API should not change between patch and minor releases.
New minor versions may add additional features to the API.
Table of Contents
- Getting Started
- Installing
- Opening a database
- Transactions
- Read-write transactions
- Read-only transactions
- Batch read-write transactions
- Managing transactions manually
- Using buckets
- Using key/value pairs
- Autoincrementing integer for the bucket
- Iterating over keys
- Prefix scans
- Range scans
- ForEach()
- Nested buckets
- Database backups
- Statistics
- Read-Only Mode
- Mobile Use (iOS/Android)
- Resources
- Comparison with other databases
- Postgres, MySQL, & other relational databases
- LevelDB, RocksDB
- LMDB
- Caveats & Limitations
- Reading the Source
- Known Issues
- Other Projects Using Bolt
Getting Started
Installing
To start using bbolt, install Go and run go get:
sh
$ go get go.etcd.io/bbolt@latest
This will retrieve the library and update your go.mod and go.sum files.
To run the command line utility, execute:
sh
$ go run go.etcd.io/bbolt/cmd/bbolt@latest
Run go install to install the bbolt command line utility into
your $GOBIN path, which defaults to $GOPATH/bin or $HOME/go/bin if the
GOPATH environment variable is not set.
sh
$ go install go.etcd.io/bbolt/cmd/bbolt@latest
Importing bbolt
To use bbolt as an embedded key-value store, import as:
go
import bolt "go.etcd.io/bbolt"
db, err := bolt.Open(path, 0600, nil)
if err != nil {
returnTop issues
#778after restart, bbolt db failed to get all reachable pages 24 comments · 2024-06-26#422Support customizing the rebalance threshold19 comments · 2023-03-14#939MADV_RANDOM causes significant increase in major page faults in Linux 6.4 and later15 comments · 2025-04-08#694Incremental etcd defrag11 comments · 2024-02-13#789Refactor freelist management & add more dedicated tests9 comments · 2024-07-08#1324Tx.Page from a read transaction concurrent with a writer aborts the process with "concurrent map read and map write"5 comments · 2026-11-10#665Introduce qemu to verify all the existing platforms5 comments · 2024-01-04#581Ensure the check command do not panic5 comments · 2023-10-18
Discussions
#964Panic with slice bounds out of range0 comments · 2025-05-20#962Inconsistent Read Behavior During Concurrent Writes.2 comments · 2025-05-15#881What is the fastest way to compare two Bolt databases?0 comments · 2025-01-06#866Freelist endgame?0 comments · 2024-11-26#864Does Tx.WriteTo need to have Tx open for entire duration of io.CopyN?3 comments · 2024-10-30#725cant do the single writer, multiple reader process. i cant even read from another single process1 comments · 2024-04-17#685Is it possible that BBolt cannot delete a key when the storage has no space left?1 comments · 2024-01-30
Latest release
v1.5.0 v1.5.0 2026-06-21See the CHANGELOG/v1.5.0 for more details.