diff --git a/include/rsdb/rsdb.h b/include/rsdb/rsdb.h index 48bbd84..ad24c55 100644 --- a/include/rsdb/rsdb.h +++ b/include/rsdb/rsdb.h @@ -48,7 +48,7 @@ class DB { bool Get(const std::string &key, std::string *data); - int Delete(const std::string &key); + bool Delete(const std::string &key); bool Valid() const; diff --git a/src/db.cpp b/src/db.cpp index ddc1204..43c9d76 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -36,7 +36,7 @@ bool rsdb::DB::Get(const std::string &key, std::string *data) { return ret; } -int rsdb::DB::Delete(const std::string &key) { +bool rsdb::DB::Delete(const std::string &key) { Slice key_slice(key); return impl_->Delete(key_slice); } diff --git a/src/db_impl.cpp b/src/db_impl.cpp index 1ae7b78..f7a1ae4 100644 --- a/src/db_impl.cpp +++ b/src/db_impl.cpp @@ -258,21 +258,20 @@ char *rsdb::DB::DBImpl::DBReadDat(DBContext *ct) { return (ct->datbuf); } -int rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) { - int rc = 0; - DBContext ct; +bool rsdb::DB::DBImpl::Delete(const rsdb::Slice &key) { + bool ret = true; lock_guard lk(idx_muts[DBHash(key) + 1]); if (DBFindAndLock(&ct, key, true) == 0) { DBDoDelete(&ct); this->cnt_delok++; } else { - rc = -1; + ret = false; this->cnt_delerr++; } if (un_lock(this->idxfd, ct.chainoff, SEEK_SET, 1) < 0) err_dump("DBImpl::Delete: un_lock error"); - return (rc); + return ret; } void rsdb::DB::DBImpl::DBDoDelete(DBContext *ct) { diff --git a/src/db_impl.h b/src/db_impl.h index 3af159a..c8b20f2 100644 --- a/src/db_impl.h +++ b/src/db_impl.h @@ -30,7 +30,7 @@ struct rsdb::DB::DBImpl { bool Get(const Slice &key, Slice *data); - int Delete(const Slice &key); + bool Delete(const Slice &key); bool Valid() const;