Keploy logo
Memcached logo

Keploy as a Memcached testing framework

Keploy mocks Memcached by recording its protocol beneath your client, capturing every get, set, miss, and expiry exactly as the daemon replied, then replaying them during tests. No memcached runs in CI and no in-process fake stands in for it.

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

What Keploy gives a Memcached team

Captured at the Memcached protocol

Keploy reads the text and binary protocols beneath your client, recording each command and reply in order — so a miss replies END exactly as the daemon did, not as a stub's default.

  • Below pymemcache, memcached-client, and gomemcache
  • Text and binary protocols
  • Flags and expiry captured
  • Multi-get responses preserved
The problem

Why Memcached 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 Memcached: by hand, with a running memcached, or with Keploy

A real daemon gives true expiry and flags behaviour and still needs to run somewhere. Keploy records those exchanges once and replays them with nothing running.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Memcached 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.py
hand-written
# Hand-written stub: no expiry, no flags, no eviction.
class StubCache:
def __init__(self):
self._values = {"order:ord_1": {"id": "ord_1", "state": "NEW"}}
 
def get(self, key):
# Always a hit. The fallthrough path never runs.
return self._values.get(key)
 
def set(self, key, value, expire=0):
# The expire argument is accepted and discarded.
self._values[key] = value
return True

The expiry is accepted and thrown away, so passing seconds where a Unix timestamp was meant is impossible to catch. Every read is a hit.

a running memcached1–2 hours
test_cache_real.py
tool-assisted
# A real memcached daemon in the test environment.
import time
from pymemcache.client.base import Client
 
def test_order_cache():
client = Client(("localhost", 11211))
client.flush_all()
 
cache = OrderCache(client)
cache.set("order:ord_1", {"state": "NEW"}, expire=1)
 
assert cache.get("order:ord_1") is not None
 
# Real expiry means really waiting for it.
time.sleep(1.5)
 
assert cache.get("order:ord_1") is None

Accurate down to expiry semantics — and it needs a daemon running, a flush between tests, and a real sleep to observe expiry.

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: Memcached
name: mock-6
spec:
exchanges:
- request: "get order:ord_1"
# The real miss reply — the branch stubs skip.
response: "END"
- request: "set order:ord_1 0 300 34"
response: "STORED"
- request: "get order:ord_1"
response: "VALUE order:ord_1 0 34"
flags: 0
expiry_seconds: 300

The recorded sequence includes the miss, the set with its real flags and expiry, and the subsequent hit — the whole cache path as it happened.

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

Keploy vs the alternatives

Memcached 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 Memcached app once, replay it forever

Keploy sits below your Memcached 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 Memcached service and captures the dependency calls it makes.

Memcached logo
Your Memcached app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+2 more Memcached 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

Memcached clients Keploy records, driver by driver

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

Quick start

Your first Memcached test suite in under five minutes

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

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "./orders-service"
  3. 3Exercise the paths you care about

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

    curl localhost:8080/orders/ord_1
    curl localhost:8080/orders/ord_1
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

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

Ready to try it on your own Memcached service?

Ecosystem

Works with the rest of your Memcached stack

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

FAQ

Memcached 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.