redis/redis
Configuration
Redis configuration lives in three places:
- A configuration file parsed at startup (commonly
redis.conforsentinel.conf). - Command-line arguments that override the file (
./redis-server /path/redis.conf --port 7000). CONFIG SETat runtime via the wire protocol.
The implementation is src/config.c (~160 KB). It defines a single static table, configs[], where each row maps a user-visible name to a type, a default value, a parser, a validator, an apply callback, and flags.
File format
Lines look like:
maxmemory 4gb
appendonly yes
save 3600 1
save 300 100
save 60 10000
bind 127.0.0.1 -::1
user alice on >password ~* +@read
include /etc/redis/local.conf
loadmodule /usr/lib/redis/redis-tls.soComments start with #. Blank lines are ignored. include <path> recursively loads another file. Quoted strings ('foo bar', "foo \"bar\"") preserve whitespace and escapes.
The redis.conf shipped in the repo root is the canonical reference for every option. Each option's behaviour is documented in the comment block above the directive — this is the de facto user manual.
Option types
src/config.c defines several config kinds via macro families:
| Macro family | Type |
|---|---|
createBoolConfig |
yes/no. |
createStringConfig |
UTF-8 string (or NULL). |
createEnumConfig |
One of a fixed set (e.g. loglevel). |
createIntConfig, createUIntConfig, createSizeTConfig, createLongLongConfig, createULongLongConfig, createOffTConfig, createTimeTConfig |
Numeric with optional range and unit suffix. |
createSpecialConfig |
Hand-rolled getter/setter for options that don't fit the above (e.g. save, bind, user). |
Each entry includes:
- The user-facing name.
- The internal storage location (often
&server.<field>). - Default value.
- Min/max for numeric.
- Modifiable flag — whether
CONFIG SETcan change it at runtime, or only at startup. - Hidden flag — diagnostic-only options that don't appear in
CONFIG GET *. - An optional
applycallback that runs after a successful set (e.g. resizing the replication backlog whenrepl-backlog-sizechanges).
Special directives
A few directives are too structural to fit the table:
save <seconds> <changes>— multiple values, parsed intoserver.saveparams.bind <addr> [<addr> ...]— a list of strings, normalised bybindparser.user <name> on/off >pwd ~pat &chan +cmd -cmd— ACL user definitions, parsed bysrc/acl.c.replicaof <host> <port>— synonymsslaveof(legacy) — parsed inline.loadmodule <path> [<args>...]— module load directive, parsed bysrc/module.c.include <path>— file inclusion.sentinel monitor,sentinel set, etc. — Sentinel-specific directives recognised only when the binary is in Sentinel mode.
Runtime configuration
CONFIG GET <pattern> returns name/value pairs.
CONFIG SET <name> <value> updates a single option (or atomically updates several when given multiple name/value pairs in Redis 7+). Options that aren't modifiable reject the call.
CONFIG REWRITE rewrites the configuration file on disk to reflect the current runtime state. It preserves the original layout and comments — the algorithm walks the file line by line and updates only those lines that have changed. It also adds new lines for options that weren't in the file but have non-default runtime values.
CONFIG RESETSTAT zeros the runtime stats counters (commands processed, key hits/misses, evictions, etc.) without touching configuration.
Hidden / debug-only options
Some options are useful to developers and dangerous to operators. They have the hidden flag and don't appear in CONFIG GET * unless requested by name. Examples:
enable-debug-command— controls whetherDEBUGis dispatched.enable-module-command— controls whetherMODULE LOAD/UNLOADworks.enable-protected-configs— when off, refusesCONFIG SET dir,dbfilename, etc.
These are intentionally discoverable only when you know to look for them.
Module configuration
Modules can register configs via RedisModule_RegisterStringConfig (and the bool / numeric / enum variants). The configs surface in CONFIG GET/CONFIG SET as <modulename>.<name> (e.g. redisearch.maxsearchresults). They also persist through CONFIG REWRITE.
Where to start modifying
- Add a new option — append a row to the
configs[]table insrc/config.cplus an entry inredis.conf(andredis-full.confif applicable). Implement anapplycallback if the change requires action. - Change a default — edit the default in the table and update
redis.conf. - Add a config kind — extend the parser via a new
createXxxConfigmacro and a typed setter.
Related pages
- Patterns and conventions — convention for adding options.
- Deployment — operator-facing recommendations for the most-tuned options.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.