CONFIG-REWRITE(3valkey)
πΎ CONFIG-REWRITE (3valkey) β¨
okay so bestie, this one's from the Valkey Command Manual β yes the Valkey one, not that other guy β and it's genuinely iconic. sit down, hydrate, let's go π«Ά
πΈ NAME πΈ
config-rewrite β it persists the effective configuration to file. no cap. it writes that thing down so it stays. π
π SYNOPSIS π
CONFIG REWRITE
that's it. that's the whole vibe. one command, zero arguments, maximum main character energy. π
π DESCRIPTION π
so the CONFIG REWRITE command rewrites the valkey.conf file the server was started with, applying the minimal changes needed to make it reflect the configuration currently used by the server β which may be different compared to the original one, because of the use of the valkey-config-set(7) CONFIG SET command. like, you changed stuff at runtime, and now the file is out here looking outdated. not on this command's watch. π
the rewrite is performed in a very conservative way:
- Comments and the overall structure of the original
valkey.confare preserved as much as possible. it's respectful like that. β¨ - If an option already exists in the old
valkey.conffile, it will be rewritten at the same position (line number). same seat, new fit. πͺ - If an option was not already present, but it is set to its default value, it is not added by the rewrite process. if it ain't broke, don't add it, fr fr.
- If an option was not already present, but it is set to a non-default value, it is appended at the end of the file. new friends go at the back of the line π§
- Non used lines are blanked. For instance if you used to have multiple
savedirectives, but the current configuration has fewer or none as you disabled RDB persistence, all the lines will be blanked. gone but not deleted, just... quiet. π
CONFIG REWRITE is also able to rewrite the configuration file from scratch if the original one no longer exists for some reason. she's resourceful, she can rebuild. πͺ
however β and this is the important part β if the server was started without a configuration file at all, the CONFIG REWRITE will just return an error. no file, no rewrite. sorry babe π
π₯ Atomic rewrite process π₯
in order to make sure the valkey.conf file is always consistent β that is, on errors or crashes you always end with the old file, or the new one β the rewrite is performed with a single write(2) call that has enough content to be at least as big as the old file. one shot, no half-finished mess. slay. β¨
sometimes additional padding in the form of comments is added in order to make sure the resulting file is big enough, and later the file gets truncated to remove the padding at the end. it's giving "we overpacked and then cleaned up before the photos" πΈ
π REPLY π
valkey-protocol(7) Simple string reply: OK when the configuration was rewritten properly. otherwise an error is returned. that's the whole tea. β
β‘ COMPLEXITY β‘
O(1) β constant time, baby. she's fast AND she's thorough. π
π ACL CATEGORIES π
@admin @dangerous @slow
so like, she's got range. admin energy, dangerous energy, and she takes her sweet time. respect. π
π HISTORY π
- Available since:
2.8.0β an elder, a legend, a queen who's been here since forever π
π SEE ALSO π
the whole friend group, no one left out:
acl(3valkey),acl-cat(3valkey),acl-deluser(3valkey),acl-dryrun(3valkey),acl-genpass(3valkey),acl-getuser(3valkey),acl-help(3valkey),acl-list(3valkey),acl-load(3valkey),acl-log(3valkey),acl-save(3valkey),acl-setuser(3valkey),acl-users(3valkey),acl-whoami(3valkey)bgrewriteaof(3valkey),bgsave(3valkey)command(3valkey),command-count(3valkey),command-docs(3valkey),command-getkeys(3valkey),command-getkeysandflags(3valkey),command-help(3valkey),command-info(3valkey),command-list(3valkey),commandlog(3valkey),commandlog-get(3valkey),commandlog-help(3valkey),commandlog-len(3valkey),commandlog-reset(3valkey)config(3valkey),config-get(3valkey),config-help(3valkey),config-resetstat(3valkey),config-set(3valkey)dbsize(3valkey),debug(3valkey),failover(3valkey),flushall(3valkey),flushdb(3valkey),info(3valkey),lastsave(3valkey)latency(3valkey),latency-doctor(3valkey),latency-graph(3valkey),latency-help(3valkey),latency-histogram(3valkey),latency-history(3valkey),latency-latest(3valkey),latency-reset(3valkey)lolwut(3valkey)(yes, that one π)memory(3valkey),memory-doctor(3valkey),memory-help(3valkey),memory-malloc-stats(3valkey),memory-purge(3valkey),memory-stats(3valkey),memory-usage(3valkey)module(3valkey),module-help(3valkey),module-list(3valkey),module-load(3valkey),module-loadex(3valkey),module-unload(3valkey),monitor(3valkey)psync(3valkey),replconf(3valkey),replicaof(3valkey),restore-asking(3valkey),role(3valkey)save(3valkey),shutdown(3valkey)slowlog(3valkey),slowlog-get(3valkey),slowlog-help(3valkey),slowlog-len(3valkey),slowlog-reset(3valkey)swapdb(3valkey),sync(3valkey),time(3valkey)
and that's the page bestie!! π¦ this gorgeous little writeup is from the Valkey 9.0.0 manual, dated 2025-10-21 β go rewrite that config, you absolute legend πβ¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms