10 int main(int argc, char **argv){
18 /* create the object */
21 tchdbsetcache(hdb, 5000000);
22 tchdbtune(hdb, 9000000, -1, 16, 0);
24 /* open the database */
25 if(!tchdbopen(hdb, "casket.hdb", HDBOWRITER | HDBOCREAT)){
26 ecode = tchdbecode(hdb);
27 fprintf(stderr, "open error: %s\n", tchdberrmsg(ecode));
30 for (i=0; i<NITEMS; i++) {
33 sprintf(mkey, "This is htable item %d", i);
34 sprintf(data, "Data for key %d", i);
35 if (!tchdbputasync2(hdb, mkey, data)) {
36 ecode = tchdbecode(hdb);
37 fprintf(stderr, "put error: %s\n", tchdberrmsg(ecode));
40 strcpy(save_key, mkey);
44 /* retrieve records */
45 value = tchdbget2(hdb, save_key);
47 printf("%s\n", value);
50 ecode = tchdbecode(hdb);
51 fprintf(stderr, "get error: %s\n", tchdberrmsg(ecode));
54 /* traverse records */
56 while((key = tchdbiternext2(hdb)) != NULL){
57 value = tchdbget2(hdb, key);
59 printf("%s:%s\n", key, value);
65 /* close the database */
67 ecode = tchdbecode(hdb);
68 fprintf(stderr, "close error: %s\n", tchdberrmsg(ecode));
71 /* delete the object */