void TripodClient::getMissedKeys(const DataMap& res, const KeySeq& keys, KeySeq& missedKeys) { for(KeySeq::const_iterator it = keys.begin(); it != keys.end(); ++it) { if(res.find(*it) == res.end()) { missedKeys.push_back(*it); } } }
bool CacheManagerI::loadListCache(const std::string& key, const std::string& namespace_id, const std::string& business_id, bool use_master, const Ice::Current& current) { std::ostringstream otem; otem << "CacheManageI::loadListCache() key:" << key << "\tnamespace_id:" << namespace_id << "\tbusiness_id:" << business_id; MyUtil::InvokeClient ic = MyUtil::InvokeClient::create(current, otem.str(), MyUtil::InvokeClient::INVOKE_LEVEL_INFO); ProducerManagerClientPtr producer = getProducer(); if(producer == NULL) { return false; } KeySeq keys; keys.push_back(key); DataMap data = producer->produce(keys, business_id, use_master, 0); if (data.empty()) { return true; } std::string list_key; StrList list_value; DataMap::const_iterator iter = data.begin(); list_key = iter->second; for (; iter != data.end(); ++iter) { list_value.push_back(iter->first); } RedisCacheClientPtr redis_client = GetRedisCache(); redis_client->Set(list_key, list_value, namespace_id, business_id); return true; }
void MenuCacheManagerI::load(const UserIdSeq& userIds, const Ice::Current& current) { MCE_INFO("[MenuCacheManagerI::load] userIds.size = " << userIds.size()); KeySeq keys; for (vector<int>::const_iterator it = userIds.begin(); it != userIds.end(); ++it) { string userIdStr = boost::lexical_cast<string>(*it); keys.push_back(TripodHelper::getCacheTypeStr(RECENTLY) + SPLITTOR + userIdStr); keys.push_back(TripodHelper::getCacheTypeStr(FAVORITE) + SPLITTOR + userIdStr); } addKeysToLoad(keys); }
PropertiesManage::KeySeq PropertiesManage::getKeys() const { KeySeq keys; for(unsigned long i = 0; i < props_.size(); i += 2) { keys.push_back (props_[i]) ; } return keys; }
PropertiesManage::KeySeq PropertiesManage::getKeys(const char* prefix) const { KeySeq keys; int prefLen = strlen(prefix); for(unsigned long i = 0; i < props_.size(); i += 2) { if(strncmp(props_[i].c_str(), prefix, prefLen) == 0) { keys.push_back (props_[i]) ; } } return keys; }
bool CacheManagerClient::LoadListCache(const std::string& key, const std::string& namespace_id, const std::string& biz_id, bool use_master) { CacheManagerConfigClientPtr config = getConfig(); if(config == NULL) { TRIPOD_WARN("CacheManagerClient::LoadListCache config is NULL, namespaceId " + namespace_id + " businessId " + biz_id); MCE_WARN("CacheManagerClient::LoadListCache config is NULL, namespaceId " + namespace_id + " businessId " + biz_id); return false; } KeySeq keys; keys.push_back(key); std::map<CacheManagerPrx, KeySeq> prx_map = config->getPrxToKeysMap(keys); std::map<CacheManagerPrx, KeySeq>::const_iterator iter = prx_map.begin(); for (; iter != prx_map.end(); ++iter) { const KeySeq& seq = iter->second; BOOST_FOREACH(const std::string& k, seq) { iter->first->loadListCache(k, namespace_id, biz_id, use_master); } }