public static Alliance GetAlliance(long allianceId) { Alliance alliance; if (ResourcesManager.InMemoryAlliancesContain(allianceId)) { return(ResourcesManager.GetInMemoryAlliance(allianceId)); } var alliancedb = m_vDatabase.GetAlliance(allianceId); alliancedb.Wait(); alliance = alliancedb.Result; if (alliance != null) { ResourcesManager.AddAllianceInMemory(alliance); return(alliance); } return(null); }
public static Alliance GetAlliance(long allianceId) { var alliance = default(Alliance); // Try to get alliance from memory first then db. // Could be improved. if (ResourcesManager.InMemoryAlliancesContain(allianceId)) { return(ResourcesManager.GetInMemoryAlliance(allianceId)); } alliance = DatabaseManager.Instance.GetAlliance(allianceId); if (alliance != null) { ResourcesManager.AddAllianceInMemory(alliance); } return(alliance); }
/*public static void LoadAllAlliancesFromDB() * { * ResourcesManager.AddAllianceInMemory(m_vDatabase.GetAllAlliances()); * }*/ public static Alliance GetAlliance(long allianceId) { Alliance alliance; if (ResourcesManager.InMemoryAlliancesContain(allianceId)) { return(ResourcesManager.GetInMemoryAlliance(allianceId)); } else { alliance = m_vDatabase.GetAlliance(allianceId); if (alliance != null) { ResourcesManager.AddAllianceInMemory(alliance); } else { return(null); } return(alliance); } }