bool NFCBigMapRedisModule::GetGridBaseInfo(const std::vector<std::string>& strGridID, std::vector<NFMsg::BigMapGridBaseInfo>& xBaseInfoList) { NF_SHARE_PTR<NFIRedisClient> pNoSqlDriver = m_pNoSqlModule->GetDriverBySuitConsistent(); if (pNoSqlDriver) { std::vector<std::string> vValues; std::string strKey = GetGridBaseKey(); std::string strData; if (pNoSqlDriver->HMGET(strKey, strGridID, vValues)) { for (int i = 0; i < vValues.size(); ++i) { const std::string& strData = vValues[i]; NFMsg::BigMapGridBaseInfo xBaseInfo; if (xBaseInfo.ParseFromString(strData)) { xBaseInfoList.push_back(xBaseInfo); } } return true; } } return false; }
NF_SHARE_PTR<NFIPropertyManager> NFCCommonRedisModule::GetPropertyInfo(const NFGUID& self, const std::string& strClassName, std::vector<std::string>& vKeyCacheList, std::vector<std::string>& vValueCacheList) { //TODO optimize NF_SHARE_PTR<NFIPropertyManager> pPropertyManager = NewPropertyManager(strClassName); if (!pPropertyManager) { return nullptr; } NF_SHARE_PTR<NFIRedisClient> pDriver = m_pNoSqlModule->GetDriverBySuit(self.ToString()); if (!pDriver) { return nullptr; } //TODO //just run this function one time NF_SHARE_PTR<NFIProperty> xProperty = pPropertyManager->First(); while (xProperty) { if (xProperty->GetCache() || xProperty->GetSave()) { vKeyCacheList.push_back(xProperty->GetKey()); } xProperty = pPropertyManager->Next(); } //cache std::string strCacheKey = GetPropertyCacheKey(self); if (!pDriver->HMGET(strCacheKey, vKeyCacheList, vValueCacheList)) { return nullptr; } if (vKeyCacheList.size() == vValueCacheList.size()) { ConvertVectorToPropertyManager(vKeyCacheList, vValueCacheList, pPropertyManager); return pPropertyManager; } return nullptr; }
NF_SHARE_PTR<NFIRecordManager> NFCCommonRedisModule::GetRecordInfo(const NFGUID& self, const std::string& strClassName, std::vector<std::string>& vKeyCacheList, std::vector<std::string>& vValueCacheList) { NF_SHARE_PTR<NFIRecordManager> pRecordManager = NewRecordManager(strClassName); if (!pRecordManager.get()) { return nullptr; } NF_SHARE_PTR<NFIRedisClient> pDriver = m_pNoSqlModule->GetDriverBySuit(self.ToString()); if (!pDriver) { return nullptr; } //TODO //just run this function one time NF_SHARE_PTR<NFIRecord> xRecord = pRecordManager->First(); while (xRecord) { if (xRecord->GetCache() || xRecord->GetSave()) { vKeyCacheList.push_back(xRecord->GetName()); } xRecord = pRecordManager->Next(); } //cache std::string strCacheKey = GetRecordCacheKey(self); if (!pDriver->HMGET(strCacheKey, vKeyCacheList, vValueCacheList)) { return nullptr; } if (vKeyCacheList.size() == vValueCacheList.size()) { ConvertVectorToRecordManager(vKeyCacheList, vValueCacheList, pRecordManager); return pRecordManager; } return nullptr; }