作者: 韩晨旭 10225101440 李畅 10225102463
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

26 行
544 B

  1. #include "leveldb/db.h"
  2. #include <iostream>
  3. using namespace std;
  4. using namespace leveldb;
  5. int main() {
  6. DB* db = nullptr;
  7. Options op;
  8. op.create_if_missing = true;
  9. Status status = DB::Open(op, "testdb", &db);
  10. assert(status.ok());
  11. db->Put(WriteOptions(), "001", "leveldb", 5);
  12. string s;
  13. auto stat = db->Get(ReadOptions(), "001", &s);
  14. cout<<s<<endl;
  15. db->Put(WriteOptions(), "002", "world");
  16. string s1;
  17. db->Delete(WriteOptions(), "002");
  18. db->Get(ReadOptions(), "002", &s1);
  19. cout<<s1<<endl;
  20. delete db;
  21. return 0;
  22. }