作者: 韩晨旭 10225101440 李畅 10225102463
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
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. }