-
-
Save kou-yeung/9791877e17959a46348ba6eee48e6401 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CardDatas getMasterCardDataByIds(const std::vector<uint32_t>& masterCardIds) const | |
{ | |
// キャッシュされないID 一覧を作成 | |
std::vector<uint32_t> needCache; | |
for (const auto& id : masterCardIds) | |
{ | |
if (_cardDataCache.fetch(id) == nullptr) needCache.push_back(id); | |
} | |
// キャッシュされないものをストレージから取得する | |
if(needCache.size() > 0) | |
{ | |
DatabaseManager::getInstance()->query(needCache, [this](CardDataPtr cardData) | |
{ | |
_cardDataCache.store(cardData); | |
}); | |
} | |
// キャッシュからカードデータ一覧を作成する | |
std::vector<CardDataPtr> result; | |
result.reserve(masterCardIds.size()); | |
for (const auto& id : masterCardIds) | |
{ | |
result.push_back(_cardDataCache.fetch(id)); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment