Created
December 2, 2020 15:51
-
-
Save charsyam/e9baf556b4e3b2877865091720b22f09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rocksdb/db.h" | |
#include <iostream> | |
int main(int argc, char *argv[]) { | |
rocksdb::DB* db; | |
rocksdb::Options options; | |
options.create_if_missing = true; | |
rocksdb::Status status = rocksdb::DB::Open(options, argv[1], &db); | |
std::cout << status.ok() << std::endl; | |
std::string key1 = "key1"; | |
std::string key2 = "key2"; | |
std::string value; | |
std::string value1 = "Key1:Value1"; | |
std::string value2; | |
rocksdb::Status s = db->Put(rocksdb::WriteOptions(), key1, value1); | |
s = db->Get(rocksdb::ReadOptions(), key1, &value); | |
std::cout << "key1 " << value << std::endl; | |
if (s.ok()) { | |
s = db->Put(rocksdb::WriteOptions(), key2, value); | |
db->Get(rocksdb::ReadOptions(), key2, &value2); | |
std::cout << "key2 " << value2 << std::endl; | |
} | |
if (s.ok()) { | |
s = db->Delete(rocksdb::WriteOptions(), key1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment