cdbmake(1)

πŸ“¦
version 0.78.2 Β· 2 versions
  • 0.78.2 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • nixpkgs unstable
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’Ύ cdbmake β€” create a constant database

okay so welcome to the cdbmake(1) page bestie, this one's from the General Commands Manual and it is lowkey iconic ✨

✨ NAME ✨

cdbmake β€” create a constant database 🫢


🌸 SYNOPSIS 🌸

cdbmake cdb cdb.tmp

πŸ’– DESCRIPTION πŸ’–

So cdbmake reads a whole bunch of encoded records off its standard input, and then it writes a constant database out to cdb. that's it, that's the job. no cap.

The main character move here is that cdbmake makes sure cdb gets updated atomically, which means programs reading cdb literally never have to sit around waiting for cdbmake to finish. not even for a sec. the way it does this? first it writes the whole database to cdb.tmp, and then it moves cdb.tmp on top of cdb. πŸŽ€

heads up bestie: if cdb.tmp already exists, it gets destroyed. gone. no thoughts, no trace. πŸ™ˆ

The directories that contain cdb.tmp and cdb have to be writable by cdbmake, and they also have to be on the same filesystem. both of those, fr fr. πŸ¦‹

cdbmake always makes sure cdb.tmp is safely written to disk before it goes and replaces cdb. so if the input is in a bad format, or if cdbmake has literally any trouble writing cdb.tmp to disk, it complains and leaves cdb alone. it does not touch your database. it does not risk it. respect. πŸ’…

πŸ“ RECORD FORMAT πŸ“

Records are indexed by keys, and a key is a string. cdb is structured so that another program can start from a key and quickly find the relevant record. speed, elegance, keys ✨

cdbmake allows several records with the same key β€” yeah, it's allowed, it's fine β€” although most readers take only the first record, and cdbmake slows down somewhat if there are many records with the same key. so like, possible β‰  free, iykyk 😭

cdbmake and cdbdump(1) preserve the order of records. periodt. πŸ‘‘

A record is encoded for cdbmake 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 data is indicated by an extra newline. For example:

+3,5:one->Hello
+3,7:two->Goodbye

key and data may contain any characters, including colons, dashes, newlines, and nulls. anything. truly anything. 🌈

Keys and data do not have to fit into memory. a database cannot exceed 4 gigabytes. ⭐

cdb is portable across machines. πŸŒπŸ’œ


πŸ‘€ SEE ALSO πŸ‘€


okay that's the whole page bestie, go build a constant database, you're gonna slay πŸ’–

this has been cdbmake(1) from the General Commands Manual β€” mwah, bye, drink water πŸ«ΆπŸŒΈπŸŽ€

πŸ“¦ where this page comes from