private Task AddPageToCache(uint currentPage, Leaders leaders) { if (!this.leaders.ContainsKey(currentPage)) { this.leaders.Add(currentPage, leaders); } App.cache.Set <Dictionary <uint, Leaders> >("leaderboard", this.leaders); return(Task.CompletedTask); }
public async Task Cache(uint maxPage) { for (uint i = 1; i <= maxPage; i++) { if (this.leaders.ContainsKey(i)) { continue; } Leaders leaders = await WakaTimeRepo.GetLeaders(i); // Create thread to set the cache, prevent stuttering this.AddPageToCache(i, leaders); } }
internal async Task <Leaders> GetPage(uint currentPage) { if (this.leaders.ContainsKey(currentPage)) { this.leaders.TryGetValue(currentPage, out Leaders value); return(value); } Leaders leaders = await WakaTimeRepo.GetLeaders(currentPage); // Create thread to set the cache, prevent stuttering this.AddPageToCache(currentPage, leaders); return(leaders); }