示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }