[关闭]
@breakerthb 2016-12-02T08:38:11.000000Z 字数 761 阅读 1682

SSDB (levelDB)

DB


SSDB

1. 下载

GitHub : https://github.com/ideawu/ssdb

2. SSDB使用

http://www.cnblogs.com/dyfblog/p/5894518.html

3. ssdb-cli使用

http://ssdb.io/docs/zh_cn/ssdb-cli.html

C++ 连接 SSDB

http://ssdb.io/docs/cpp/

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文件可以直接执行。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注