本文整理汇总了C++中leveldb::DB::Delete方法的典型用法代码示例。如果您正苦于以下问题:C++ DB::Delete方法的具体用法?C++ DB::Delete怎么用?C++ DB::Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类leveldb::DB
的用法示例。
在下文中一共展示了DB::Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Delete
Status Delete(const std::string& key)
{
leveldb::Status s = db->Delete(leveldb::WriteOptions(), key);
if (s.ok())
{
return Status::OK();
}
return Status::NotFound();
}
示例2: Failure
Future<bool> LevelDBStorageProcess::expunge(const Entry& entry)
{
if (error.isSome()) {
return Failure(error.get());
}
// We do a read first to make sure the version has not changed. This
// could be optimized in the future, for now it will probably hit
// the cache anyway.
Try<Option<Entry> > option = read(entry.name());
if (option.isError()) {
return Failure(option.error());
}
if (option.get().isNone()) {
return false;
}
if (UUID::fromBytes(option.get().get().uuid()) !=
UUID::fromBytes(entry.uuid())) {
return false;
}
// Note that the read (i.e., DB::Get) and DB::Delete are inherently
// "atomic" because only one db can be opened at a time, so there
// can not be any writes that occur concurrently.
leveldb::WriteOptions options;
options.sync = true;
leveldb::Status status = db->Delete(options, entry.name());
if (!status.ok()) {
return Failure(status.ToString());
}
return true;
}