1
This commit is contained in:
parent
e35c00b915
commit
7d2c689d06
@ -83,7 +83,8 @@ a8::XObject DBEngine::GetConnInfo(const std::string& data)
|
|||||||
|
|
||||||
a8::XObject DBEngine::GetConnInfo(long long data)
|
a8::XObject DBEngine::GetConnInfo(long long data)
|
||||||
{
|
{
|
||||||
std::shared_ptr<a8::XObject> mysql_cluster_conf = JsonDataMgr::Instance()->GetMysqlClusterConf();
|
std::shared_ptr<a8::XObject> mysql_cluster_conf =
|
||||||
|
JsonDataMgr::Instance()->GetMysqlClusterConf();
|
||||||
if (mysql_cluster_conf->Size() <= 0) {
|
if (mysql_cluster_conf->Size() <= 0) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -93,22 +94,49 @@ a8::XObject DBEngine::GetConnInfo(long long data)
|
|||||||
|
|
||||||
void DBEngine::UpdateFriendApplyIdx(long long crc32_code, long long new_idx)
|
void DBEngine::UpdateFriendApplyIdx(long long crc32_code, long long new_idx)
|
||||||
{
|
{
|
||||||
friend_apply_idx_hash_[crc32_code] = new_idx;
|
if (GetFriendApplyCurrIdx(crc32_code) < new_idx) {
|
||||||
|
friend_apply_idx_hash_[GetInstanceId(crc32_code)] = new_idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long long DBEngine::GetFriendApplyCurrIdx(long long crc32_code)
|
long long DBEngine::GetFriendApplyCurrIdx(long long crc32_code)
|
||||||
{
|
{
|
||||||
auto itr = friend_apply_idx_hash_.find(crc32_code);
|
auto itr = friend_apply_idx_hash_.find(GetInstanceId(crc32_code));
|
||||||
return itr != friend_apply_idx_hash_.end() ? itr->second : 0;
|
return itr != friend_apply_idx_hash_.end() ? itr->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBEngine::UpdateGroupApplyIdx(long long crc32_code, long long new_idx)
|
void DBEngine::UpdateGroupApplyIdx(long long crc32_code, long long new_idx)
|
||||||
{
|
{
|
||||||
group_apply_idx_hash_[crc32_code] = new_idx;
|
if (GetGroupApplyCurrIdx(crc32_code) < new_idx) {
|
||||||
|
group_apply_idx_hash_[GetInstanceId(crc32_code)] = new_idx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long long DBEngine::GetGroupApplyCurrIdx(long long crc32_code)
|
long long DBEngine::GetGroupApplyCurrIdx(long long crc32_code)
|
||||||
{
|
{
|
||||||
auto itr = group_apply_idx_hash_.find(crc32_code);
|
auto itr = group_apply_idx_hash_.find(GetInstanceId(crc32_code));
|
||||||
return itr != group_apply_idx_hash_.end() ? itr->second : 0;
|
return itr != group_apply_idx_hash_.end() ? itr->second : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long long DBEngine::GetEventCurrIdx(long long crc32_code)
|
||||||
|
{
|
||||||
|
auto itr = event_idx_hash_.find(GetInstanceId(crc32_code));
|
||||||
|
return itr != event_idx_hash_.end() ? itr->second : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBEngine::UpdateEventIdx(long long crc32_code, long long new_idx)
|
||||||
|
{
|
||||||
|
if (GetEventCurrIdx(crc32_code) < new_idx) {
|
||||||
|
event_idx_hash_[crc32_code] = new_idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DBEngine::GetInstanceId(long long crc32_code)
|
||||||
|
{
|
||||||
|
std::shared_ptr<a8::XObject> mysql_cluster_conf =
|
||||||
|
JsonDataMgr::Instance()->GetMysqlClusterConf();
|
||||||
|
if (mysql_cluster_conf->Size() <= 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return crc32_code % mysql_cluster_conf->Size();
|
||||||
|
}
|
||||||
|
@ -34,13 +34,19 @@ class DBEngine : public a8::Singleton<DBEngine>
|
|||||||
|
|
||||||
long long GetFriendApplyCurrIdx(long long crc32_code);
|
long long GetFriendApplyCurrIdx(long long crc32_code);
|
||||||
long long GetGroupApplyCurrIdx(long long crc32_code);
|
long long GetGroupApplyCurrIdx(long long crc32_code);
|
||||||
|
long long GetEventCurrIdx(long long crc32_code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateFriendApplyIdx(long long crc32_code, long long new_idx);
|
void UpdateFriendApplyIdx(long long crc32_code, long long new_idx);
|
||||||
void UpdateGroupApplyIdx(long long crc32_code, long long new_idx);
|
void UpdateGroupApplyIdx(long long crc32_code, long long new_idx);
|
||||||
|
void UpdateEventIdx(long long crc32_code, long long new_idx);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int GetInstanceId(long long crc32_code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<long long, long long> friend_apply_idx_hash_;
|
std::map<long long, long long> friend_apply_idx_hash_;
|
||||||
std::map<long long, long long> group_apply_idx_hash_;
|
std::map<long long, long long> group_apply_idx_hash_;
|
||||||
|
std::map<long long, long long> event_idx_hash_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user