Skip to content

Commit 55c6799

Browse files
haowu14facebook-github-bot
authored andcommitted
Remove return type for lookup/removeAsync
Summary: As title. We have only one possible return value. Reviewed By: therealgymmy Differential Revision: D40962097 fbshipit-source-id: 6895984d3d9c34d58f0ed12526da0e4b02202c58
1 parent 4e04c43 commit 55c6799

File tree

5 files changed

+21
-45
lines changed

5 files changed

+21
-45
lines changed

cachelib/allocator/nvmcache/NvmCache-inl.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,11 @@ typename NvmCache<C>::WriteHandle NvmCache<C>::find(HashedKey hk) {
182182
XDCHECK(ctx);
183183
auto guard = folly::makeGuard([hk, this]() { removeFromFillMap(hk); });
184184

185-
auto status = navyCache_->lookupAsync(
185+
navyCache_->lookupAsync(
186186
HashedKey::precomputed(ctx->getKey(), hk.keyHash()),
187187
[this, ctx](navy::Status s, HashedKey k, navy::Buffer v) {
188188
this->onGetComplete(*ctx, s, k, v.view());
189189
});
190-
191-
XDCHECK_EQ(status, navy::Status::Ok);
192-
193190
guard.dismiss();
194191
return hdl;
195192
}
@@ -257,17 +254,14 @@ typename NvmCache<C>::WriteHandle NvmCache<C>::peek(folly::StringPiece key) {
257254

258255
// no need for fill lock or inspecting the state of other concurrent
259256
// operations since we only want to check the state for debugging purposes.
260-
auto status = navyCache_->lookupAsync(
257+
navyCache_->lookupAsync(
261258
HashedKey{key}, [&, this](navy::Status st, HashedKey, navy::Buffer v) {
262259
if (st != navy::Status::NotFound) {
263260
auto nvmItem = reinterpret_cast<const NvmItem*>(v.data());
264261
hdl = createItem(key, *nvmItem);
265262
}
266263
b.post();
267264
});
268-
if (status != navy::Status::Ok) {
269-
return hdl;
270-
}
271265
b.wait();
272266
return hdl;
273267
}
@@ -843,11 +837,8 @@ void NvmCache<C>::remove(HashedKey hk, DeleteTombStoneGuard tombstone) {
843837
static_cast<int>(status)));
844838
};
845839

846-
auto status = navyCache_->removeAsync(
847-
HashedKey::precomputed(ctx.key(), hk.keyHash()), delCleanup);
848-
if (status != navy::Status::Ok) {
849-
delCleanup(status, HashedKey::precomputed("", 0));
850-
}
840+
navyCache_->removeAsync(HashedKey::precomputed(ctx.key(), hk.keyHash()),
841+
delCleanup);
851842
}
852843

853844
template <typename C>

cachelib/navy/AbstractCache.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class AbstractCache {
8585
//
8686
// @key must be valid till delayed async job execution, no copy is made. It
8787
// is user responsibility to make a copy if needed (capture in callback).
88-
//
89-
// Returns: Ok, Rejected
90-
virtual Status lookupAsync(HashedKey key, LookupCallback cb) = 0;
88+
virtual void lookupAsync(HashedKey key, LookupCallback cb) = 0;
9189

9290
// Removes from the index, space reused after reclamation.
9391
// Returns: Ok, NotFound
@@ -97,9 +95,7 @@ class AbstractCache {
9795
// Callback is optional.
9896
//
9997
// See @lookupAsync about @key lifetime.
100-
//
101-
// Returns: Ok, Rejected
102-
virtual Status removeAsync(HashedKey key, RemoveCallback cb) = 0;
98+
virtual void removeAsync(HashedKey key, RemoveCallback cb) = 0;
10399

104100
// Executes all queued operations and makes sure result is reflected on the
105101
// device.

cachelib/navy/block_cache/tests/BlockCacheTest.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -314,27 +314,22 @@ TEST(BlockCache, AsyncCallbacks) {
314314
MockLookupCB cbLookup;
315315
EXPECT_CALL(cbLookup, call(Status::Ok, makeHK("key"), makeView("value")));
316316
EXPECT_CALL(cbLookup, call(Status::NotFound, makeHK("cat"), BufferView{}));
317-
EXPECT_EQ(Status::Ok,
318-
driver->lookupAsync(
319-
makeHK("key"),
320-
[&cbLookup](Status status, HashedKey key, Buffer value) {
321-
cbLookup.call(status, key, value.view());
322-
}));
323-
EXPECT_EQ(Status::Ok,
324-
driver->lookupAsync(
325-
makeHK("cat"),
326-
[&cbLookup](Status status, HashedKey key, Buffer value) {
327-
cbLookup.call(status, key, value.view());
328-
}));
317+
driver->lookupAsync(makeHK("key"),
318+
[&cbLookup](Status status, HashedKey key, Buffer value) {
319+
cbLookup.call(status, key, value.view());
320+
});
321+
322+
driver->lookupAsync(makeHK("cat"),
323+
[&cbLookup](Status status, HashedKey key, Buffer value) {
324+
cbLookup.call(status, key, value.view());
325+
});
329326
driver->flush();
330327

331328
MockRemoveCB cbRemove;
332329
EXPECT_CALL(cbRemove, call(Status::Ok, makeHK("key")));
333330
EXPECT_CALL(cbRemove, call(Status::NotFound, makeHK("cat")));
334-
EXPECT_EQ(Status::Ok,
335-
driver->removeAsync(makeHK("key"), toCallback(cbRemove)));
336-
EXPECT_EQ(Status::Ok,
337-
driver->removeAsync(makeHK("cat"), toCallback(cbRemove)));
331+
driver->removeAsync(makeHK("key"), toCallback(cbRemove));
332+
driver->removeAsync(makeHK("cat"), toCallback(cbRemove));
338333
driver->flush();
339334
}
340335

cachelib/navy/driver/Driver.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,17 @@ Status Driver::lookup(HashedKey hk, Buffer& value) {
171171
return enginePairs_[selectEnginePair(hk)].lookupSync(hk, value);
172172
}
173173

174-
Status Driver::lookupAsync(HashedKey hk, LookupCallback cb) {
174+
void Driver::lookupAsync(HashedKey hk, LookupCallback cb) {
175175
XDCHECK(cb);
176176
enginePairs_[selectEnginePair(hk)].scheduleLookup(hk, std::move(cb));
177-
return Status::Ok;
178177
}
179178

180179
Status Driver::remove(HashedKey hk) {
181180
return enginePairs_[selectEnginePair(hk)].removeSync(hk);
182181
}
183182

184-
Status Driver::removeAsync(HashedKey hk, RemoveCallback cb) {
183+
void Driver::removeAsync(HashedKey hk, RemoveCallback cb) {
185184
enginePairs_[selectEnginePair(hk)].scheduleRemove(hk, std::move(cb));
186-
return Status::Ok;
187185
}
188186

189187
void Driver::flush() {

cachelib/navy/driver/Driver.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ class Driver final : public AbstractCache {
105105
// @param key the item key to lookup
106106
// @param cb a callback function be triggered when the lookup complete,
107107
// the result will be provided to the function.
108-
// @return a status indicates success or failure enqueued, and the reason
109-
// for failure
110-
Status lookupAsync(HashedKey key, LookupCallback cb) override;
108+
void lookupAsync(HashedKey key, LookupCallback cb) override;
111109

112110
// remove the key from cache
113111
// @param key the item key to be removed
@@ -117,9 +115,7 @@ class Driver final : public AbstractCache {
117115
// remove the key from cache asynchronously.
118116
// @param key the item key to be removed
119117
// @param cb a callback function be triggered when the remove complete.
120-
// @return a status indicates success or failure enqueued, and the reason
121-
// for failure
122-
Status removeAsync(HashedKey key, RemoveCallback cb) override;
118+
void removeAsync(HashedKey key, RemoveCallback cb) override;
123119

124120
// ensure all pending job have been completed and data has been flush to
125121
// device(s).

0 commit comments

Comments
 (0)