热门问题
时间线
聊天
视角
LevelDB
来自维基百科,自由的百科全书
Remove ads
LevelDB是一个由Google公司所研发的键-值存储嵌入式数据库管理系统编程库,[2] 以开源的BSD许可证发布。[3]
特征
例子
储存键/值对,和查询键的值:
#include "leveldb/db.h"
#include <iostream>
using namespace std;
int main(){
  leveldb::DB *db;
  leveldb::Options options;
  options.create_if_missing = true;
  // 開啟數據庫
  leveldb::DB::Open(options, "/tmp/testdb", &db);
  // 鍵 = MyKey29,值 = "Hello World!"
  string key = "MyKey29", value = "Hello World!", result;
  // 儲存 鍵/值對
  db->Put(leveldb::WriteOptions(), key, value);
  // 查詢 MyKey29 鍵的值
  db->Get(leveldb::ReadOptions(), key, &result);
  // 輸出值到屏幕
  cout << "result = " << result << endl;
  // 關閉數據庫
  delete db;
  return 0;
}
Remove ads
(LevelDB安装目录为:leveldb-read-only)[6]
% g++ test.cc -Ileveldb-read-only/include -Lleveldb-read-only -lleveldb -lpthread % ./a.out result = Hello World!
RocksDB
语言的绑定
参见
参考文献
外部链接
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads