Open-Source Wikis

/

Redis

/

Reference

/

Configuration

redis/redis

Configuration

Redis configuration lives in three places:

  1. A configuration file parsed at startup (commonly redis.conf or sentinel.conf).
  2. Command-line arguments that override the file (./redis-server /path/redis.conf --port 7000).
  3. CONFIG SET at 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.so

Comments 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 SET can change it at runtime, or only at startup.
  • Hidden flag — diagnostic-only options that don't appear in CONFIG GET *.
  • An optional apply callback that runs after a successful set (e.g. resizing the replication backlog when repl-backlog-size changes).

Special directives

A few directives are too structural to fit the table:

  • save <seconds> <changes> — multiple values, parsed into server.saveparams.
  • bind <addr> [<addr> ...] — a list of strings, normalised by bind parser.
  • user <name> on/off >pwd ~pat &chan +cmd -cmd — ACL user definitions, parsed by src/acl.c.
  • replicaof <host> <port> — synonyms slaveof (legacy) — parsed inline.
  • loadmodule <path> [<args>...] — module load directive, parsed by src/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 whether DEBUG is dispatched.
  • enable-module-command — controls whether MODULE LOAD/UNLOAD works.
  • enable-protected-configs — when off, refuses CONFIG 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 in src/config.c plus an entry in redis.conf (and redis-full.conf if applicable). Implement an apply callback 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 createXxxConfig macro and a typed setter.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Configuration – Redis wiki | Factory