From 8a2016aaea0f579cc5dcea9c909bc8ca1ec16926 Mon Sep 17 00:00:00 2001 From: John Sully Date: Tue, 5 Mar 2024 03:22:24 +0000 Subject: [PATCH] Enable key cache for async reads --- src/StorageCache.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/StorageCache.cpp b/src/StorageCache.cpp index 0feca8e9e..ba307fc68 100644 --- a/src/StorageCache.cpp +++ b/src/StorageCache.cpp @@ -209,18 +209,22 @@ void StorageCache::retrieve(sds key, IStorage::callbackSingle fn) const } StorageToken *StorageCache::begin_retrieve(struct aeEventLoop *el, aePostFunctionTokenProc proc, sds *rgkey, size_t ckey) { -#if 0 std::unique_lock ul(m_lock); if (m_pdict != nullptr) { - uint64_t hash = dictSdsHash(key); - dictEntry *de = dictFind(m_pdict, reinterpret_cast(hash)); - - if (de == nullptr) - return nullptr; // Not found + bool fAnyKey = false; + for (size_t ik = 0; ik < ckey; ++ik) { + uint64_t hash = dictSdsHash(rgkey[ik]); + dictEntry *de = dictFind(m_pdict, reinterpret_cast(hash)); + + if (de != nullptr) + fAnyKey = true; + } + if (!fAnyKey) + return nullptr; // All keys are missing - skip the io } ul.unlock(); -#endif + return m_spstorage->begin_retrieve(el, proc, rgkey, ckey); }