Refactor zone expedition caching

This optimizes caching all expeditions by loading dynamic zone data and
expedition members in bulk instead of for each expedition separately.
This reduces the number of queries from 1+2n to 3 total.

Expedition members are now joined in the initial query since empty
expeditions aren't cached anyway. Optional internal lockouts for all
cached expeditions are loaded in a single bulk query afterwards.

Dynamic Zone data is also loaded as a single bulk query afterwards to
simplify processing and keep dz database logic separated. It might be
worth investigating if joining dz data in the initial expeditions load
query is worth refactoring for.
This commit is contained in:
hg
2020-05-30 23:03:01 -04:00
parent 8ae063f953
commit 158d934df7
6 changed files with 254 additions and 156 deletions
+23 -1
View File
@@ -38,12 +38,14 @@ namespace ExpeditionDatabase
uint32_t InsertExpedition(
uint32_t instance_id, const std::string& expedition_name, uint32_t leader_id,
uint32_t min_players, uint32_t max_players, bool has_replay_lockout);
std::string LoadExpeditionsSelectQuery();
MySQLRequestResult LoadExpedition(uint32_t expedition_id);
MySQLRequestResult LoadAllExpeditions();
MySQLRequestResult LoadCharacterLockouts(uint32_t character_id);
MySQLRequestResult LoadCharacterLockouts(uint32_t character_id, const std::string& expedition_name);
MySQLRequestResult LoadExpeditionMembers(uint32_t expedition_id);
MySQLRequestResult LoadValidationData(const std::string& character_names_query, const std::string& expedition_name);
std::unordered_map<uint32_t, std::unordered_map<std::string, ExpeditionLockoutTimer>>
LoadMultipleExpeditionLockouts(const std::vector<uint32_t>& expedition_ids);
void DeleteAllCharacterLockouts(uint32_t character_id);
void DeleteAllCharacterLockouts(uint32_t character_id, const std::string& expedition_name);
void DeleteCharacterLockout(uint32_t character_id, const std::string& expedition_name, const std::string& event_name);
@@ -70,4 +72,24 @@ namespace ExpeditionDatabase
void UpdateReplayLockoutOnJoin(uint32_t expedition_id, bool add_on_join);
};
namespace LoadExpeditionColumns
{
enum eLoadExpeditionColumns
{
id = 0,
instance_id,
expedition_name,
leader_id,
min_players,
max_players,
has_replay_timer,
add_replay_on_join,
is_locked,
leader_name,
member_id,
is_current_member,
member_name
};
};
#endif