小组成员:10215300402-朱维清 & 10222140408 谷杰
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 rivejä
528 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");
  12. string s;
  13. 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. }