Keploy logo
Redis logo

Keploy as a Redis testing framework

Keploy mocks Redis by recording the RESP protocol beneath your client, capturing every GET, SET, TTL, and pipeline response exactly as the server replied, then replaying them during tests. No Redis runs in CI and no in-process fake is substituted for the real server.

Generate Redis tests free
keploy record -c "./orders-service"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Redis team

Captured at RESP over TCP

Keploy reads the RESP protocol beneath your client, recording each command and reply in order — so pipelines and MULTI/EXEC blocks replay as the multi-reply exchanges they really were.

  • Below Lettuce, ioredis, redis-py, go-redis
  • Commands and replies kept in order
  • Pipelines and transactions preserved
  • Real nil replies, not a stub default
The problem

Why Redis integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing Redis: by hand, with miniredis / fakeredis, or with Keploy

miniredis and fakeredis implement a documented subset of Redis in-process, so anything past common string and hash commands can diverge. Keploy replays what your real server sent.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Redis vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
cache_stub.go
hand-written
// Hand-written stub: no TTL, no eviction, no miss behaviour.
package cache
 
import "time"
 
type StubCache struct {
values map[string]string
}
 
func NewStubCache() *StubCache {
return &StubCache{values: map[string]string{
"order:ord_1": `{"id":"ord_1","state":"NEW"}`,
}}
}
 
func (s *StubCache) Get(key string) (string, error) {
// Always a hit. The fallthrough path is never exercised.
return s.values[key], nil
}
 
func (s *StubCache) SetEX(key, val string, ttl time.Duration) error {
// The TTL argument is accepted and discarded.
s.values[key] = val
return nil
}

The TTL is accepted and thrown away, so passing milliseconds where seconds were meant is impossible to catch. Every read is a hit.

miniredis / fakeredis1–2 hours
cache_miniredis_test.go
tool-assisted
// miniredis: an in-process Redis reimplementation.
package cache
 
import (
"testing"
"time"
"github.com/alicebob/miniredis/v2"
"github.com/redis/go-redis/v9"
)
 
func TestOrderCache(t *testing.T) {
srv := miniredis.RunT(t)
rdb := redis.NewClient(&redis.Options{Addr: srv.Addr()})
 
c := New(rdb)
_ = c.SetEX("order:ord_1", `{"state":"NEW"}`, 60*time.Second)
 
got, err := c.Get("order:ord_1")
if err != nil || got == "" {
t.Fatalf("expected a hit, got %q err %v", got, err)
}
 
// Time must be advanced manually; it is not real expiry.
srv.FastForward(61 * time.Second)
 
if _, err := c.Get("order:ord_1"); err != redis.Nil {
t.Fatal("expected the key to have expired")
}
}

A real improvement on the stub, and still a reimplementation: expiry is simulated with FastForward, and anything outside the implemented command set may diverge.

With Keploy~5 minutes
mocks.yaml
auto-generated
# Recorded with: keploy record -c './orders-service'
# Two real exchanges: a miss, then the write-back.
version: api.keploy.io/v1beta1
kind: Redis
name: mock-7
spec:
exchanges:
- request: ["GET", "order:ord_1"]
# The real miss reply — this is the branch stubs skip.
response: null
- request: ["SETEX", "order:ord_1", "60", "{\"state\":\"NEW\"}"]
response: "OK"
- request: ["TTL", "order:ord_1"]
response: 60
- request: ["GET", "order:ord_1"]
response: "{\"state\":\"NEW\"}"

The recorded sequence includes the miss, the write-back with its real TTL argument, and the subsequent hit — the whole cache path, captured as it happened.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

Redis testing tools, compared

The options a team on caches and search stores actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your Redis app once, replay it forever

Keploy sits below your Redis process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a Redis service and captures the dependency calls it makes.

Redis logo
Your Redis app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+4 more Redis clients
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

Redis clients Keploy records, driver by driver

Keploy captures Redis at the wire protocol, so 6 of these 8 clients need no adapter, no test double, and no Redis instance in CI.

Quick start

Your first Redis test suite in under five minutes

Every command below runs against your existing Redis service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    One binary on the recording machine. Nothing is installed into Redis and no client wrapper is needed.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record with your development Redis reachable

    Run the app as usual. Every command and reply is captured in order, misses included.

    keploy record -c "./orders-service"
  3. 3Exercise both cache branches

    Hit an endpoint on a cold key to record the miss and write-back, then hit it again to record the hit.

    redis-cli DEL order:ord_1
    curl localhost:8080/orders/ord_1 # records the miss
    curl localhost:8080/orders/ord_1 # records the hit
  4. 4Replay with Redis stopped

    Shut Redis down and run the suite. If replay passes, every command your code issues is answered by a recorded mock.

    keploy test -c "./orders-service" --delay 8

Ready to try it on your own Redis service?

Ecosystem

Works with the rest of your Redis stack

Keploy records at the network layer, so framework and driver choices inside your Redis app do not change how it captures traffic.

FAQ

Redis testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.