1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
.TH cdbmake 1
.SH NAME
cdbmake \- create a constant database
.SH SYNOPSIS
.B cdbmake
.I cdb
.I cdb.tmp
.SH DESCRIPTION
.B cdbmake
reads a series of encoded records from its standard input and writes a
constant database to
.IR cdb .
.P
.B cdbmake
ensures that
.I cdb
is updated atomically, so programs reading
.I cdb
never have to wait for
.B cdbmake
to finish.
It does this by first writing the database to
.I cdb.tmp
and then moving
.I cdb.tmp
on top of
.IR cdb .
If
.I cdb.tmp
already exists, it is destroyed.
The directories containing
.I cdb.tmp
and
.I cdb
must be writable to
.BR cdbmake ;
they must also be on the same filesystem.
.P
.B cdbmake
always makes sure that
.I cdb.tmp
is safely written to disk before it replaces
.IR cdb .
If the input is in a bad format or if
.B cdbmake
has any trouble writing
.I cdb.tmp
to disk,
.B cdbmake
complains and leaves
.I cdb
alone.
.SS RECORD FORMAT
Records are indexed by keys.
A key is a string.
.I cdb
is structured so that another program, starting from a key, can quickly find
the relevant record.
.B cdbmake
allows several records with the same key, although most readers take only
the first record, and
.B cdbmake
slows down somewhat if there are many records with the same key.
.P
.B cdbmake
and
.BR cdbdump (1)
preserve the order of records.
.P
A record is encoded for
.B cdbmake
as +\fIklen\fR,\fIdlen\fR:\fIkey\fR->\fIdata\fR followed by a newline.
Here
.I klen
is the number of bytes in
.I key
and
.I dlen
is the number of bytes in
.IR data .
The end of
.I data
is indicated by an extra newline.
For example:
.P
+3,5:one->Hello
+3,7:two->Goodbye
.P
.I key
and
.I data
may contain any characters, including colons, dashes, newlines, and nulls.
.P
Keys and data do not have to fit into memory.
A database cannot exceed 4 gigabytes.
.P
.I cdb
is portable across machines.
.SH SEE ALSO
cdbdump(1),
cdbget(1),
cdbstats(1)
|