提供array和hashtable的存储引擎层的二进制安全支持,把入口函数修改为接收参数长度,将strlen、strcmp、strcpy替换。
This commit is contained in:
@@ -67,21 +67,21 @@ void testcase(int connfd, uint8_t op, const char* key, const char* value, rsp_re
|
||||
|
||||
void array_testcase_1w(int connfd) {
|
||||
|
||||
int count = 1;
|
||||
int count = 10000;
|
||||
int i = 0;
|
||||
|
||||
struct timeval tv_begin;
|
||||
gettimeofday(&tv_begin, NULL);
|
||||
|
||||
for (i = 0;i < count;i ++) {
|
||||
testcase(connfd, KVS_CMD_SET, "nage", "lian", KVS_STATUS_OK, NULL, "SET NAME");
|
||||
testcase(connfd, KVS_CMD_GET, "nage", NULL, KVS_STATUS_OK, "lian", "GET NAME");
|
||||
testcase(connfd, KVS_CMD_MOD, "nage", "liu", KVS_STATUS_OK, NULL, "MOD NAME");
|
||||
testcase(connfd, KVS_CMD_GET, "nage", NULL, KVS_STATUS_OK, "liu", "GET NAME");
|
||||
testcase(connfd, KVS_CMD_HSET, "nage", "lian", KVS_STATUS_OK, NULL, "SET NAME");
|
||||
testcase(connfd, KVS_CMD_HGET, "nage", NULL, KVS_STATUS_OK, "lian", "GET NAME");
|
||||
testcase(connfd, KVS_CMD_HMOD, "nage", "liu", KVS_STATUS_OK, NULL, "MOD NAME");
|
||||
testcase(connfd, KVS_CMD_HGET, "nage", NULL, KVS_STATUS_OK, "liu", "GET NAME");
|
||||
|
||||
testcase(connfd, KVS_CMD_EXIST, "nage", NULL, KVS_STATUS_EXIST, NULL, "EXIST NAME");
|
||||
testcase(connfd, KVS_CMD_DEL, "nage", NULL, KVS_STATUS_OK, NULL, "DEL NAME");
|
||||
testcase(connfd, KVS_CMD_EXIST, "nage", NULL, KVS_STATUS_NO_EXIST, NULL, "NOT EXIST NAME");
|
||||
testcase(connfd, KVS_CMD_HEXIST, "nage", NULL, KVS_STATUS_EXIST, NULL, "EXIST NAME");
|
||||
testcase(connfd, KVS_CMD_HDEL, "nage", NULL, KVS_STATUS_OK, NULL, "DEL NAME");
|
||||
testcase(connfd, KVS_CMD_HEXIST, "nage", NULL, KVS_STATUS_NO_EXIST, NULL, "NOT EXIST NAME");
|
||||
}
|
||||
|
||||
struct timeval tv_end;
|
||||
@@ -98,11 +98,14 @@ void do_batch_example(int fd)
|
||||
kvs_batch_t batch;
|
||||
kvs_batch_init(&batch);
|
||||
|
||||
char key[10]={0}, val[10]={0};
|
||||
|
||||
// 组 batch(最多 64 条)
|
||||
kvs_batch_add(&batch, KVS_CMD_SET, "k1", "v1");
|
||||
kvs_batch_add(&batch, KVS_CMD_SET, "k2", "v2");
|
||||
kvs_batch_add(&batch, KVS_CMD_GET, "k1", NULL);
|
||||
kvs_batch_add(&batch, KVS_CMD_GET, "k2", NULL);
|
||||
for(int i = 0;i < 24; ++ i){
|
||||
int len = sprintf(key, "k%d", i);
|
||||
len = sprintf(val, "v%d", i);
|
||||
kvs_batch_add(&batch, KVS_CMD_HSET, key, val);
|
||||
}
|
||||
|
||||
// 一次性发送
|
||||
kvs_batch_send(fd, &batch);
|
||||
@@ -118,10 +121,13 @@ void do_batch_example(int fd)
|
||||
PRESP("BATCH", &rsps[i]);
|
||||
}
|
||||
|
||||
printf("%d\n", nrsp);
|
||||
|
||||
testcase(fd, KVS_CMD_GET, "k1", NULL, KVS_STATUS_OK, "v1", "GET k1");
|
||||
testcase(fd, KVS_CMD_GET, "k2", NULL, KVS_STATUS_OK, "v2", "GET k2");
|
||||
for(int i = 0;i < 24; ++ i){
|
||||
int len = sprintf(key, "k%d", i);
|
||||
len = sprintf(val, "v%d", i);
|
||||
testcase(fd, KVS_CMD_HGET, key, NULL, KVS_STATUS_OK, val, "GET K");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -136,8 +142,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int connfd = connect_tcpserver(ip, port);
|
||||
|
||||
// array_testcase_1w(connfd);
|
||||
do_batch_example(connfd);
|
||||
array_testcase_1w(connfd);
|
||||
// do_batch_example(connfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user