redis/redis
How to contribute
This section documents how to work in the Redis codebase: branch model, build/test/PR cycle, how to run tests, how to debug a misbehaving instance, and which conventions to follow.
The official high-level contribution policy is in CONTRIBUTING.md. The pages here zoom in on the engineering aspects: practical commands and conventions a contributor needs day to day.
Quick links
- Development workflow — branches, PR process, what reviewers look for.
- Testing — Tcl integration suite, embedded C unit tests, module tests, sentinel/cluster suites.
- Debugging — logs, watchdog,
DEBUGcommand, gdb tricks. - Patterns and conventions — coding style, error handling, memory rules, command tables.
- Tooling — code generation, CI, validators.
Where to start
- Read Patterns and conventions first. Redis has a strong, opinionated style. Anything that violates the style will be rejected in review regardless of correctness.
- Build the binary with
makefrom the repo root. See Getting started. - Run
./runtestto see the test harness pass before changing anything. - Find the file by command name.
SETis insrc/t_string.c,LPUSHis insrc/t_list.c,XADDis insrc/t_stream.c. Server-wide things are insrc/server.c. Networking is insrc/networking.c. The mapping is by data type or subsystem, not by alphabetical concern. - Add the spec in
src/commands/*.jsonif you are adding a new command, then runmake commands.defto regenerate the table. - Write a Tcl test in
tests/unit/...exercising the new behaviour. - Open a PR to
unstable. Daily CI will run the full matrix, including TLS, cluster, sentinel, ASAN, MSAN, valgrind, FreeBSD, and macOS builds.
Where things go
| You want to add... | You edit... |
|---|---|
| A new command | src/commands/<name>.json (or <group>-<name>.json) + the C function in the appropriate src/t_*.c or src/<subsystem>.c + a Tcl test in tests/unit/. |
| A new subcommand of an existing command | The same JSON file (subcommand fields nest) and an extra C handler. |
| A new configuration option | src/config.c table + an entry in redis.conf (and redis-full.conf if applicable). |
| A new data type | A new src/t_<type>.c, register it in commands.def via JSON, add encoding constants in src/object.h, plus persistence (src/rdb.c) and replication hooks. |
| A new module API symbol | src/redismodule.h (the public header) and the implementation in src/module.c. |
| A bug fix in cluster | Likely src/cluster.c, src/cluster_legacy.c, or src/cluster_asm.c. |
Reviewer expectations
Pull requests are reviewed against the Redis style: minimal allocations, clear control flow, no needless abstraction. Practical heuristics:
- No
goto errcascades unless the surrounding code already uses them. Some files (e.g.src/networking.c,src/cluster.c) consistently usegoto cleanup-style flow; others (e.g.src/t_string.c) use early returns. Match the file you are editing. - No
strdup/mallocdirectly. Usezmalloc(),zcalloc(),zfree(),zstrdup()so the memory is accounted for inINFO memory. - No hidden allocations in command paths. Anything that could fail or churn memory should be visible at the call site.
- A passing CI run is the bar. Daily CI exercises ~24 build/test variants. New code should not regress any of them.
See Development workflow for the actual mechanics.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.