miniredis

A pure Go, in-memory Redis server for fast, dependency-free unit tests.

Library
Go
vv2.38.0
3,602stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity56
Maintenance44
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture78
Code Quality82
Innovation68
Learning Curve55

Miniredis implements a real Redis server in pure Go, purpose-built for use inside Go unit tests. It runs in-process alongside your test binary and exposes a genuine TCP interface that any Redis client can connect to, so code under test talks to it exactly as it would talk to production Redis — no mocking layer, no interface abstraction to maintain, and no external redis-server binary to install in CI.

Because the server lives in the same process as the test, you can also bypass the network entirely and assert against stored values directly (s.Get("foo"), s.HGetAll("some")), or manipulate time-based behavior like TTL expiry with FastForward() — something that’s awkward to do reliably against a real Redis instance. It implements a large, actively maintained subset of the Redis command set spanning strings, hashes, lists, sets, sorted sets, streams, pub/sub, transactions, and Lua scripting via EVAL.

What You Get

  • A real TCP-speaking Redis server you can start and stop per-test with a single miniredis.RunT(t) call and automatic cleanup
  • Direct in-process accessors (Get, HGetAll, Exists, …) for seeding fixtures and asserting on state without a client round-trip
  • Manual time control via FastForward(d) and SetTime(t) to deterministically test TTL expiry and time-dependent logic
  • Broad command coverage across strings, hashes, lists, sets, sorted sets, streams, pub/sub, transactions, and Lua scripting (EVAL/EVALSHA)
  • An integration test suite that runs the same command set against a real Redis binary to catch behavioral drift
  • Zero external process dependencies — no need to install or manage a redis-server binary in CI

Common Use Cases

  • Unit-testing application code that reads and writes to Redis without spinning up a real Redis container
  • Testing cache-expiry and TTL logic deterministically using FastForward() instead of real sleeps
  • Verifying pub/sub and transaction (MULTI/EXEC/WATCH) flows in isolation, in-process, per test
  • Running fast CI pipelines that avoid provisioning and networking a real Redis service container
  • Exercising Lua EVAL/EVALSHA scripting paths in application code without a live Redis dependency

Under The Hood

Architecture The package splits cleanly along two axes: a server/ subpackage (server.go, proto.go) implements the RESP wire protocol and TCP connection lifecycle independent of Redis semantics, while the root package implements Redis command behavior itself, spread across one file per command family (cmd_string.go, cmd_hash.go, cmd_list.go, cmd_stream.go, cmd_scripting.go, and so on) that register handlers against a shared Miniredis/RedisDB state pair defined in miniredis.go and db.go. Supporting data structures — sorted sets, HyperLogLog, geohashing — live in their own files (sorted_set.go, hll.go, geo.go) and are consumed by the relevant cmd_* handlers, keeping the command-dispatch layer thin and the data-structure logic independently testable. Per-connection state (selected DB, transaction queue, auth, pub/sub subscription) is isolated in a connCtx struct threaded through each command call, so concurrent connections don’t share mutable request state beyond the mutex-guarded Miniredis instance itself.

Tech Stack Miniredis is a Go module (go 1.17) with a single external runtime dependency, github.com/yuin/gopher-lua, used to back the EVAL/EVALSHA scripting commands with an embedded Lua interpreter rather than shelling out. Everything else — the RESP protocol parser, the TCP server loop, and all command logic — is implemented against the Go standard library only, with no ORM, web framework, or database driver involved since the package itself acts as the server. A Makefile drives local builds and the integration/ subdirectory scripts fetching and building a real redis-server binary to run comparison tests against.

Code Quality The project has 26 _test.go files, generally one per command family, using only the Go standard library’s testing package rather than a third-party assertion library like testify. Errors from command handlers are returned as typed Redis protocol errors rather than swallowed, matching real Redis error semantics closely enough that client libraries built for production Redis behave the same against it. CI (.github/workflows/ci.yaml) runs the full suite across four Go versions (1.17 through 1.25) and additionally builds and runs a real Redis server for integration comparison, which is a stronger correctness signal than unit tests alone. There’s no linter or formatter step visible in CI beyond go vet/go build.

What Makes It Unique Unlike a mock or a stub, miniredis behaves like Redis at the protocol level — it accepts real client connections over TCP and understands a genuinely large slice of the Redis command surface, including transactions, pub/sub, and Lua scripting, rather than just the handful of commands a typical hand-rolled mock would cover. Its explicit, manual time model (FastForward, SetTime) is also a deliberate departure from real Redis: TTLs don’t decay on wall-clock time, they decay only when the test advances them, which makes expiry logic deterministic and fast to test instead of dependent on real sleeps.

Used by 10 apps in this directory

Go
55%
Apache 2.0

Authgear

Authentication

2,014

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
69
Dependency
Built with
Go55%
HTML25%
TypeScript17%
Updated 4 days ago
Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,762

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go82%
Python17%
Updated 3 days ago
Go
31%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,386

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
82
Repo Health
88
Technical
63
Dependency
Built with
Go31%
Rust28%
C23%
Updated 2 days ago
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,498

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript49%
Go45%
Updated today
Go
91%
AGPL 3.0

Lago

Ecommerce · Invoicing Finance

10,444

Open-source metering, billing, and revenue infrastructure for product-led companies that need complete control over their pricing stack.

View details
86
Repo Health
81
Technical
74
Dependency
Built with
Go91%
Updated 2 days ago
Go
98%
Apache 2.0

Nightingale

Monitoring

13,272

Open-source alerting engine that connects to any time-series or log data source and routes alarms to 20+ notification channels with AI-assisted triage.

View details
96
Repo Health
77
Technical
68
Dependency
Built with
Go98%
Updated today
Go
37%
Apache 2.0

OpenSandbox

Developer Tools · Security

14,829

Secure, fast, and extensible sandbox runtime for AI agents with multi-language SDKs and Docker/Kubernetes runtimes.

View details
84
Repo Health
81
Technical
72
Dependency
Built with
Go37%
Python37%
Updated 2 days ago
Python
54%
Other

PostHog

Analytics · Monitoring · Developer Tools

39,479

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
66
Dependency
Built with
Python54%
TypeScript36%
Updated today
Go
75%
AGPL 3.0

Teleport

Security · Authentication

20,860

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Go75%
TypeScript16%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search