149
94
std::cerr << db::errormsg() << std::endl;
95
return 1;
96
}
97
98
// Remove one record
99
if (kv.remove("John") != status::OK) {
100
std::cerr << db::errormsg() << std::endl;
101
return 1;
102
}
103
104
// Look for removed record
105
assert(kv.exists("John") == status::NOT_FOUND);
106
107
// Try to use one of methods of ordered engines
108
assert(kv.get_above("John", [](string_view key, string_view
value) {
109
std::cout << "This callback should never be called" <<
std::endl;
110
return 1;
111
}) == status::NOT_SUPPORTED);
112
113
// Close database (optional)
114
kv.close();
115
116
return 0;
117
}
• Line 51: We set the pmemkv_config structure by calling config_
setup() function introduced in previous section and listing
(imported with #include "pmemkv_config.h").
• Line 55: Creates a volatile object instance of the class pmem::kv::db
which provides interface for managing persistent database.
• Line 57: Here, we open the key-value database backed by the cmap
engine using the config parameters. The cmap engine is a persistent
concurrent hash map engine, implemented in libpmemobj-cpp.
Chapter 9 pmemkv: a persistent in- memory key-value store
94
std::cerr << db::errormsg() << std::endl;
95
return 1;
96
}
97
98
// Remove one record
99
if (kv.remove("John") != status::OK) {
100
std::cerr << db::errormsg() << std::endl;
101
return 1;
102
}
103
104
// Look for removed record
105
assert(kv.exists("John") == status::NOT_FOUND);
106
107
// Try to use one of methods of ordered engines
108
assert(kv.get_above("John", [](string_view key, string_view
value) {
109
std::cout << "This callback should never be called" <<
std::endl;
110
return 1;
111
}) == status::NOT_SUPPORTED);
112
113
// Close database (optional)
114
kv.close();
115
116
return 0;
117
}
• Line 51: We set the pmemkv_config structure by calling config_
setup() function introduced in previous section and listing
(imported with #include "pmemkv_config.h").
• Line 55: Creates a volatile object instance of the class pmem::kv::db
which provides interface for managing persistent database.
• Line 57: Here, we open the key-value database backed by the cmap
engine using the config parameters. The cmap engine is a persistent
concurrent hash map engine, implemented in libpmemobj-cpp.
Chapter 9 pmemkv: a persistent in- memory key-value store
