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
99.99% Uptime for MySQL and PostgreSQL Databases Icon
99.99% Uptime for MySQL and PostgreSQL Databases

Sub-second maintenance. 2x read/write performance. Built-in vector search for AI apps.

Cloud SQL Enterprise Plus delivers near-zero downtime with 35 days of point-in-time recovery. Supports MySQL, PostgreSQL, and SQL Server.
Try Free
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