cdb(1)
cdbmake(1) β create a constant database π πΈ
okay so bestie, listen up: cdbmake is literally the tool you need if you're trying to build a constant database from encoded records. it's giving main character energy, and the way it handles atomic updates? iconic. no cap.
β¨ SYNOPSIS β¨
cdbmake f ftmp
π DESCRIPTION π
cdbmake reads a series of encoded records from its standard input and writes a constant database to a file named f, replacing any previous contents of f. yes, it fully replaces whatever was there before. periodt. π
the way it does this is so slay: cdbmake ensures that f is updated atomically, so programs reading f never have to wait for cdbmake to finish. it does this by first writing the database to ftmp and then moving ftmp on top of f. if ftmp already exists, it is destroyed. rip but make it fashion. π«Ά
the directories containing ftmp and f must be writable to cdbmake; they must also be on the same filesystem. no exceptions. β¨
cdbmake always makes sure that ftmp is safely written to disk before it replaces f. so if the input is in a bad format or if cdbmake has any trouble writing ftmp to disk, cdbmake complains and leaves f alone. it said not today. π
there is also a cdb64make that uses cdb64 format instead of cdb format. choose your fighter. π
π RECORD FORMAT π
records are indexed by keys. a key is a string. the file f is structured so that another program, starting from a key, can quickly find the relevant record. it's giving efficient. π¦
now here's the tea: cdbmake allows several records with the same key, although:
- most readers take only the first record π
cdbmakeslows down somewhat if there are many records with the same key. lowkey a warning. π
cdbmake preserves the order of records. periodt. π
for the input provided to cdbmake, each record is encoded as +klen,dlen:key->data followed by a newline. here klen is the number of bytes in key and dlen is the number of bytes in data. the end of all records is indicated by an extra newline. iykyk.
for example, here are two records:
+3,5:one->Hello
+3,7:two->Goodbye
key and data may contain any characters, including colons, dashes, newlines, and nulls. literally anything. π
keys and data do not have to fit into memory, but cdbmake needs roughly 16 bytes of memory per record. also a database cannot exceed 4 gigabytes (or 1 exabyte for cdb64make). big yikes if you try. π
f is portable across machines. slay. β¨
π SEE ALSO π
that's the whole vibe, bestie. signed, sealed, delivered by cdb(1) β no date given but you know it's cute. ππ«Ά
π¦ where this page comes from
- nixpkgs unstable: cdb 20251021
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms