Sometimes you want to test code which uses Redis, without making it a full-blown integration test. Miniredis implements (parts of) the Redis server, to be used in unittests. It enables a simple, cheap, in-memory, Redis replacement, with a real TCP interface. It saves you from using mock code, and since the redis server lives in the test process you can query for values directly, without going through the server stack. There are no dependencies on external binaries, so you can easily integrate it in automated build processes. Since miniredis is intended to be used in unittests TTLs don't decrease automatically. You can use TTL() to get the TTL (as a time.Duration) of a key. It will return 0 when no TTL is set. Miniredis will use math/rand's global RNG for randomness unless a seed is provided by calling m.Seed(...). If a seed is provided, then miniredis will use its own RNG based on that seed.

Features

  • There are no dependencies on external binaries, so you can easily integrate it in automated build processes
  • String keys
  • TTLs don't decrease automatically
  • Miniredis will use math/rand's global RNG for randomness unless a seed is provided
  • Commands which use randomness are: RANDOMKEY, SPOP, and SRANDMEMBER
  • Integration tests are run against Redis 7.0.7

Project Samples

Project Activity

See All Activity >

Categories

Frameworks

License

MIT License

Follow Miniredis

Miniredis Web Site

Other Useful Business Software
Forever Free Full-Stack Observability | Grafana Cloud Icon
Forever Free Full-Stack Observability | Grafana Cloud

Our generous forever free tier includes the full platform, including the AI Assistant, for 3 users with 10k metrics, 50GB logs, and 50GB traces.

Built on open standards like Prometheus and OpenTelemetry, Grafana Cloud includes Kubernetes Monitoring, Application Observability, Incident Response, plus the AI-powered Grafana Assistant. Get started with our generous free tier today.
Create free account
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Miniredis!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Go

Related Categories

Go Frameworks

Registered

2023-01-19