only delete if exists
This commit is contained in:
1 parent
605f369d65
commit
967bd78658
1 file changed
+5
-3
@@ -231,9 +231,11 @@ void RocksDBStorageProvider::removeExpire(const char * key, size_t cchKey, long
|
||||
std::unique_lock<fastlock> l(m_lock);
|
||||
std::string prefix((const char *)&expire,sizeof(long long));
|
||||
std::string strKey(key, cchKey);
|
||||
if (m_spbatch != nullptr)
|
||||
status = m_spbatch->Delete(m_spexpirecolfamily.get(), rocksdb::Slice(prefix + strKey), rocksdb::Slice(strKey));
|
||||
else
|
||||
rocksdb::PinnableSlice slice;
|
||||
if (m_spbatch)
|
||||
if (m_spbatch->GetFromBatchAndDB(m_spdb.get(), ReadOptions(), m_spexpirecolfamily.get(), rocksdb::Slice(prefix + strKey), &slice).ok())
|
||||
status = m_spbatch->Delete(m_spexpirecolfamily.get(), rocksdb::Slice(prefix + strKey), rocksdb::Slice(strKey));
|
||||
else if(m_spdb->Get(ReadOptions(), m_spexpirecolfamily.get(), rocksdb::Slice(prefix + strKey), &slice).ok())
|
||||
status = m_spdb->Delete(WriteOptions(), m_spexpirecolfamily.get(), rocksdb::Slice(prefix + strKey), rocksdb::Slice(strKey));
|
||||
if (!status.ok())
|
||||
throw status.ToString();
|
||||
|
||||
Reference in new issue
Block a user