@breakerthb
2016-12-02T08:38:11.000000Z
字数 761
阅读 1786
DB
GitHub : https://github.com/ideawu/ssdb
http://www.cnblogs.com/dyfblog/p/5894518.html
http://ssdb.io/docs/zh_cn/ssdb-cli.html
ssdb-stable-1.9.3/api/cpp目录下:
libssdb-client.a
SSDB_client.h
只需要这两个文件。
测试代码:
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include "SSDB_client.h"
int main(int argc, char **argv){
const char *ip = (argc >= 2)? argv[1] : "127.0.0.1";
int port = (argc >= 3)? atoi(argv[2]) : 8888;
ssdb::Client *client = ssdb::Client::connect(ip, port);
if(client == NULL){
printf("fail to connect to server!\n");
return 0;
}
ssdb::Status s;
s = client->set("k", "hello ssdb!");
if(s.ok()){
printf("k = hello ssdb!\n");
}else{
printf("error!\n");
}
delete client;
return 0;
}
编译:
$ g++ -o main main.cpp -L. -lssdb-client
生成main文件可以直接执行。