📄 tcadb.3
字号:
.TH "TCADB" 3 "2009-02-13" "Man Page" "Tokyo Cabinet".SH NAMEtcadb \- the abstract database API.SH DESCRIPTION.PPAbstract database is a set of interfaces to use on\-memory hash database, on\-memory tree database, hash database, B+ tree database, fixed\-length database, and table database with the same API..PPTo use the abstract database API, include `\fBtcutil.h\fR', `\fBtcadb.h\fR', and related standard header files. Usually, write the following description near the front of a source file..PP.RS.br\fB#include <tcutil.h>\fR.br\fB#include <tcadb.h>\fR.br\fB#include <stdlib.h>\fR.br\fB#include <stdbool.h>\fR.br\fB#include <stdint.h>\fR.RE.PPObjects whose type is pointer to `\fBTCADB\fR' are used to handle abstract databases. An abstract database object is created with the function `\fBtcadbnew\fR' and is deleted with the function `\fBtcadbdel\fR'. To avoid memory leak, it is important to delete every object when it is no longer in use..PPBefore operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one. The function `\fBtcadbopen\fR' is used to open a concrete database and the function `\fBtcadbclose\fR' is used to close the database. To avoid data missing or corruption, it is important to close every database instance when it is no longer in use..SH API.PPThe function `tcadbnew' is used in order to create an abstract database object..PP.RS.br\fBTCADB *tcadbnew(void);\fR.RSThe return value is the new abstract database object..RE.RE.PPThe function `tcadbdel' is used in order to delete an abstract database object..PP.RS.br\fBvoid tcadbdel(TCADB *\fIadb\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RE.PPThe function `tcadbopen' is used in order to open an abstract database..PP.RS.br\fBbool tcadbopen(TCADB *\fIadb\fB, const char *\fIname\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIname\fR' specifies the name of the database. If it is "*", the database will be an on\-memory hash database. If it is "+", the database will be an on\-memory tree database. If its suffix is ".tch", the database will be a hash database. If its suffix is ".tcb", the database will be a B+ tree database. If its suffix is ".tcf", the database will be a fixed\-length database. If its suffix is ".tct", the database will be a table database. Otherwise, this function fails. Tuning parameters can trail the name, separated by "#". Each parameter is composed of the name and the value, separated by "=". On\-memory hash database supports "bnum", "capnum", and "capsiz". On\-memory tree database supports "capnum" and "capsiz". Hash database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", and "xmsiz". B+ tree database supports "mode", "lmemb", "nmemb", "bnum", "apow", "fpow", "opts", "lcnum", "ncnum", and "xmsiz". Fixed\-length database supports "mode", "width", and "limsiz". Table database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", "lcnum", "ncnum", "xmsiz", and "idx"..RE.RSIf successful, the return value is true, else, it is false..RE.RSThe tuning parameter "capnum" specifies the capacity number of records. "capsiz" specifies the capacity size of using memory. Records spilled the capacity are removed by the storing order. "mode" can contain "w" of writer, "r" of reader, "c" of creating, "t" of truncating, "e" of no locking, and "f" of non\-blocking lock. The default mode is relevant to "wc". "opts" can contains "l" of large option, "d" of Deflate option, "b" of BZIP2 option, and "t" of TCBS option. "idx" specifies the column name of an index and its type separated by ":". For example, "casket.tch#bnum=1000000#opts=ld" means that the name of the database file is "casket.tch", and the bucket number is 1000000, and the options are large and Deflate..RE.RE.PPThe function `tcadbclose' is used in order to close an abstract database object..PP.RS.br\fBbool tcadbclose(TCADB *\fIadb\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RSIf successful, the return value is true, else, it is false..RE.RSUpdate of a database is assured to be written when the database is closed. If a writer opens a database but does not close it appropriately, the database will be broken..RE.RE.PPThe function `tcadbput' is used in order to store a record into an abstract database object..PP.RS.br\fBbool tcadbput(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RS`\fIvbuf\fR' specifies the pointer to the region of the value..RE.RS`\fIvsiz\fR' specifies the size of the region of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, it is overwritten..RE.RE.PPThe function `tcadbput2' is used in order to store a string record into an abstract object..PP.RS.br\fBbool tcadbput2(TCADB *\fIadb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkstr\fR' specifies the string of the key..RE.RS`\fIvstr\fR' specifies the string of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, it is overwritten..RE.RE.PPThe function `tcadbputkeep' is used in order to store a new record into an abstract database object..PP.RS.br\fBbool tcadbputkeep(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RS`\fIvbuf\fR' specifies the pointer to the region of the value..RE.RS`\fIvsiz\fR' specifies the size of the region of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, this function has no effect..RE.RE.PPThe function `tcadbputkeep2' is used in order to store a new string record into an abstract database object..PP.RS.br\fBbool tcadbputkeep2(TCADB *\fIadb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkstr\fR' specifies the string of the key..RE.RS`\fIvstr\fR' specifies the string of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf a record with the same key exists in the database, this function has no effect..RE.RE.PPThe function `tcadbputcat' is used in order to concatenate a value at the end of the existing record in an abstract database object..PP.RS.br\fBbool tcadbputcat(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, const void *\fIvbuf\fB, int \fIvsiz\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RS`\fIvbuf\fR' specifies the pointer to the region of the value..RE.RS`\fIvsiz\fR' specifies the size of the region of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf there is no corresponding record, a new record is created..RE.RE.PPThe function `tcadbputcat2' is used in order to concatenate a string value at the end of the existing record in an abstract database object..PP.RS.br\fBbool tcadbputcat2(TCADB *\fIadb\fB, const char *\fIkstr\fB, const char *\fIvstr\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkstr\fR' specifies the string of the key..RE.RS`\fIvstr\fR' specifies the string of the value..RE.RSIf successful, the return value is true, else, it is false..RE.RSIf there is no corresponding record, a new record is created..RE.RE.PPThe function `tcadbout' is used in order to remove a record of an abstract database object..PP.RS.br\fBbool tcadbout(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RSIf successful, the return value is true, else, it is false..RE.RE.PPThe function `tcadbout2' is used in order to remove a string record of an abstract database object..PP.RS.br\fBbool tcadbout2(TCADB *\fIadb\fB, const char *\fIkstr\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkstr\fR' specifies the string of the key..RE.RSIf successful, the return value is true, else, it is false..RE.RE.PPThe function `tcadbget' is used in order to retrieve a record in an abstract database object..PP.RS.br\fBvoid *tcadbget(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB, int *\fIsp\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RS`\fIsp\fR' specifies the pointer to the variable into which the size of the region of the return value is assigned..RE.RSIf successful, the return value is the pointer to the region of the value of the corresponding record. `NULL' is returned if no record corresponds..RE.RSBecause an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use..RE.RE.PPThe function `tcadbget2' is used in order to retrieve a string record in an abstract database object..PP.RS.br\fBchar *tcadbget2(TCADB *\fIadb\fB, const char *\fIkstr\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkstr\fR' specifies the string of the key..RE.RSIf successful, the return value is the string of the value of the corresponding record. `NULL' is returned if no record corresponds..RE.RSBecause the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use..RE.RE.PPThe function `tcadbvsiz' is used in order to get the size of the value of a record in an abstract database object..PP.RS.br\fBint tcadbvsiz(TCADB *\fIadb\fB, const void *\fIkbuf\fB, int \fIksiz\fB);\fR.RS`\fIadb\fR' specifies the abstract database object..RE.RS`\fIkbuf\fR' specifies the pointer to the region of the key..RE.RS`\fIksiz\fR' specifies the size of the region of the key..RE.RSIf successful, the return value is the size of the value of the corresponding record, else, it is \-1..RE.RE.PPThe function `tcadbvsiz2' is used in order to get the size of the value of a string record in an abstract database object..PP.RS.br\fBint tcadbvsiz2(TCADB *\fIadb\fB, const char *\fIkstr\fB);\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -