whatisgithub

What is badger?

dgraph-io/badger — explained in plain English

Analysis updated 2026-06-24

15,612GoAudience · developerComplexity · 3/5Setup · easy

In one sentence

BadgerDB is a fast, embeddable key-value database written in pure Go that you import as a library, no separate server to run, giving your Go program persistent local disk storage with SSD-optimized throughput.

Mindmap

mindmap
  root((BadgerDB))
    What It Is
      Embedded key-value DB
      Pure Go library
      No separate server
    Design
      LSM tree plus value log
      SSD optimized
      WiscKey research
    Features
      ACID transactions
      TTL key expiry
      Multiple key versions
    Use Cases
      Go app storage
      High-throughput cache
      Distributed systems
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add fast persistent key-value storage inside a Go application without running a separate database server process.

USE CASE 2

Store and retrieve terabytes of data on SSDs with high read and write throughput using concurrent ACID transactions.

USE CASE 3

Build a self-expiring cache or session store in Go using BadgerDB's built-in time-to-live key expiry feature.

What is it built with?

Go

How does it compare?

dgraph-io/badgerhashicorp/packergo-task/task
Stars15,61215,66615,515
LanguageGoGoGo
Setup difficultyeasymoderateeasy
Complexity3/53/52/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

So what is it?

BadgerDB is an embeddable, persistent key-value database written in pure Go. A key-value store maps unique names to chunks of data, like a dictionary that survives restarts. Because it is embeddable, you do not run it as a separate server, you import it as a library directly into your Go program and it stores data on the local disk. Badger is the underlying storage engine for Dgraph, a distributed graph database, and was created as a faster Go-native alternative to non-Go stores like RocksDB. Internally, Badger uses an LSM tree with a value log, based on the WiscKey research paper that separates keys from values to reduce write amplification on solid-state drives. Because of this design, Badger is specifically tuned for SSDs and aims for high throughput on both reads and writes, even on data sets in the terabytes range. It supports concurrent ACID transactions with serializable snapshot isolation, meaning many parts of your program can read and write at the same time without corrupting each other's view of the data. Other features include snapshots, time-to-live expiry on keys, and access to multiple versions of the same key. A nightly Jepsen-style bank test, run for hours with race detection on, exercises these transactional guarantees. You would reach for Badger when you need fast embedded storage inside a Go application and do not want the overhead of running a separate database process. Existing users include Dgraph, the Jaeger tracing platform, go-ipfs, and several distributed search and messaging projects. Installation is through go get, and a command-line tool is included for offline backup and restore. The full README is longer than what was provided.

Copy-paste prompts

Prompt 1
Write a Go program that uses BadgerDB to store and retrieve user session tokens with a 24-hour TTL, including a background goroutine that calls RunValueLogGC periodically.
Prompt 2
Using BadgerDB in Go, write a function that iterates over all key-value pairs with a given prefix and returns them as a map[string]string.
Prompt 3
Show me how to wrap two BadgerDB writes in a single ACID transaction in Go so both succeed or both roll back if one fails.
Prompt 4
What is the difference between BadgerDB and RocksDB, and when would I choose BadgerDB for an embedded Go application?
Prompt 5
How do I use the BadgerDB command-line tool to take an offline backup of a database and restore it on a different machine?

Frequently asked questions

What is badger?

BadgerDB is a fast, embeddable key-value database written in pure Go that you import as a library, no separate server to run, giving your Go program persistent local disk storage with SSD-optimized throughput.

What language is badger written in?

Mainly Go. The stack also includes Go.

How hard is badger to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is badger for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.