Skip to content

Commit 8a2016a

Browse files
committed
Enable key cache for async reads
1 parent 7a488a8 commit 8a2016a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/StorageCache.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,22 @@ void StorageCache::retrieve(sds key, IStorage::callbackSingle fn) const
209209
}
210210

211211
StorageToken *StorageCache::begin_retrieve(struct aeEventLoop *el, aePostFunctionTokenProc proc, sds *rgkey, size_t ckey) {
212-
#if 0
213212
std::unique_lock<fastlock> ul(m_lock);
214213
if (m_pdict != nullptr)
215214
{
216-
uint64_t hash = dictSdsHash(key);
217-
dictEntry *de = dictFind(m_pdict, reinterpret_cast<void*>(hash));
218-
219-
if (de == nullptr)
220-
return nullptr; // Not found
215+
bool fAnyKey = false;
216+
for (size_t ik = 0; ik < ckey; ++ik) {
217+
uint64_t hash = dictSdsHash(rgkey[ik]);
218+
dictEntry *de = dictFind(m_pdict, reinterpret_cast<void*>(hash));
219+
220+
if (de != nullptr)
221+
fAnyKey = true;
222+
}
223+
if (!fAnyKey)
224+
return nullptr; // All keys are missing - skip the io
221225
}
222226
ul.unlock();
223-
#endif
227+
224228
return m_spstorage->begin_retrieve(el, proc, rgkey, ckey);
225229
}
226230

0 commit comments

Comments
 (0)