|
|
7 kuukautta sitten | |
|---|---|---|
| .. | ||
| fb | 7 kuukautta sitten | |
| options | 7 kuukautta sitten | |
| pb | 7 kuukautta sitten | |
| skl | 7 kuukautta sitten | |
| table | 7 kuukautta sitten | |
| trie | 7 kuukautta sitten | |
| y | 7 kuukautta sitten | |
| .gitignore | 7 kuukautta sitten | |
| CHANGELOG.md | 7 kuukautta sitten | |
| CODE_OF_CONDUCT.md | 7 kuukautta sitten | |
| CONTRIBUTING.md | 7 kuukautta sitten | |
| LICENSE | 7 kuukautta sitten | |
| Makefile | 7 kuukautta sitten | |
| README.md | 7 kuukautta sitten | |
| SECURITY.md | 7 kuukautta sitten | |
| VERSIONING.md | 7 kuukautta sitten | |
| backup.go | 7 kuukautta sitten | |
| batch.go | 7 kuukautta sitten | |
| changes.sh | 7 kuukautta sitten | |
| compaction.go | 7 kuukautta sitten | |
| db.go | 7 kuukautta sitten | |
| dir_other.go | 7 kuukautta sitten | |
| dir_plan9.go | 7 kuukautta sitten | |
| dir_unix.go | 7 kuukautta sitten | |
| dir_windows.go | 7 kuukautta sitten | |
| discard.go | 7 kuukautta sitten | |
| doc.go | 7 kuukautta sitten | |
| errors.go | 7 kuukautta sitten | |
| histogram.go | 7 kuukautta sitten | |
| iterator.go | 7 kuukautta sitten | |
| key_registry.go | 7 kuukautta sitten | |
| level_handler.go | 7 kuukautta sitten | |
| levels.go | 7 kuukautta sitten | |
| logger.go | 7 kuukautta sitten | |
| managed_db.go | 7 kuukautta sitten | |
| manifest.go | 7 kuukautta sitten | |
| memtable.go | 7 kuukautta sitten | |
| merge.go | 7 kuukautta sitten | |
| options.go | 7 kuukautta sitten | |
| publisher.go | 7 kuukautta sitten | |
| stream.go | 7 kuukautta sitten | |
| stream_writer.go | 7 kuukautta sitten | |
| structs.go | 7 kuukautta sitten | |
| test.sh | 7 kuukautta sitten | |
| test_extensions.go | 7 kuukautta sitten | |
| txn.go | 7 kuukautta sitten | |
| util.go | 7 kuukautta sitten | |
| value.go | 7 kuukautta sitten | |
BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go. It is the underlying database for Dgraph, a fast, distributed graph database. It's meant to be a performant alternative to non-Go-based key-value stores like RocksDB.
Badger is stable and is being used to serve data sets worth hundreds of terabytes. Badger supports
concurrent ACID transactions with serializable snapshot isolation (SSI) guarantees. A Jepsen-style
bank test runs nightly for 8h, with --race flag and ensures the maintenance of transactional
guarantees. Badger has also been tested to work with filesystem level anomalies, to ensure
persistence and consistency. Badger is being used by a number of projects which includes Dgraph,
Jaeger Tracing, UsenetExpress, and many more.
The list of projects using Badger can be found here.
Please consult the Changelog for more detailed information on releases.
To start using Badger, install Go 1.21 or above. Badger v3 and above needs go modules. From your project, run the following command
go get github.com/dgraph-io/badger/v4
This will retrieve the library.
Badger provides a CLI tool which can perform certain operations like offline backup/restore. To install the Badger CLI, retrieve the repository and checkout the desired version. Then run
cd badger
go install .
This will install the badger command line utility into your $GOBIN path.
Badger Documentation is available at https://docs.hypermode.com/badger
Badger was written with these design goals in mind:
Badger’s design is based on a paper titled WiscKey: Separating Keys from Values in SSD-conscious Storage.
| Feature | Badger | RocksDB | BoltDB |
|---|---|---|---|
| Design | LSM tree with value log | LSM tree only | B+ tree |
| High Read throughput | Yes | No | Yes |
| High Write throughput | Yes | Yes | No |
| Designed for SSDs | Yes (with latest research 1) | Not specifically 2 | No |
| Embeddable | Yes | Yes | Yes |
| Sorted KV access | Yes | Yes | Yes |
| Pure Go (no Cgo) | Yes | No | Yes |
| Transactions | Yes, ACID, concurrent with SSI3 | Yes (but non-ACID) | Yes, ACID |
| Snapshots | Yes | Yes | Yes |
| TTL support | Yes | Yes | No |
| 3D access (key-value-version) | Yes4 | No | No |
1 The WISCKEY paper (on which Badger is based) saw big wins with separating values from keys, significantly reducing the write amplification compared to a typical LSM tree.
2 RocksDB is an SSD optimized version of LevelDB, which was designed specifically for rotating disks. As such RocksDB's design isn't aimed at SSDs.
3 SSI: Serializable Snapshot Isolation. For more details, see the blog post Concurrent ACID Transactions in Badger
4 Badger provides direct access to value versions via its Iterator API. Users can also specify how many versions to keep per key via Options.
We have run comprehensive benchmarks against RocksDB, Bolt and LMDB. The benchmarking code, and the detailed logs for the benchmarks can be found in the badger-bench repo. More explanation, including graphs can be found the blog posts (linked above).
Below is a list of known projects that use Badger:
badger.Iterator, simplifying from-to, and prefix mechanics.If you are using Badger in a project please send a pull request to add it to the list.
If you're interested in contributing to Badger see CONTRIBUTING.