/// <summary>Append the response page to the cached data.</summary>
        public virtual void CacheRequestPage(RequestFilter filter, RequestPage <ModProfile> page)
        {
            // early out if shouldn't cache
            if (!this.isCachingPermitted)
            {
                return;
            }

            // asserts
            Debug.Assert(filter != null);
            Debug.Assert(page != null);

            // cache request
            string          filterString = filter.GenerateFilterString();
            RequestPageData cachedData;

            if (this.requestCache.TryGetValue(filterString, out cachedData))
            {
                cachedData.resultTotal = page.resultTotal;

                this.requestCache[filterString] = RequestPageData.Append(cachedData,
                                                                         page.resultOffset,
                                                                         Utility.MapProfileIds(page.items));
            }
            else
            {
                cachedData = new RequestPageData()
                {
                    resultOffset = page.resultOffset,
                    resultTotal  = page.resultTotal,
                    modIds       = Utility.MapProfileIds(page.items),
                };

                this.requestCache.Add(filterString, cachedData);
            }

            // cache profiles
            foreach (ModProfile profile in page.items)
            {
                this.profileCache[profile.id] = profile;
            }

            // store
            if (this.storeIfSubscribed)
            {
                IList <int> subMods = ModManager.GetSubscribedModIds();
                foreach (ModProfile profile in page.items)
                {
                    if (subMods.Contains(profile.id))
                    {
                        CacheClient.SaveModProfile(profile);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>Append the response page to the cached data.</summary>
        public virtual void CacheRequestPage(RequestFilter filter, RequestPage <ModProfile> page)
        {
            // early out if shouldn't cache
            if (!this.isCachingPermitted)
            {
                return;
            }

            // asserts
            Debug.Assert(filter != null);
            Debug.Assert(page != null);

            // cache request
            string          filterString = filter.GenerateFilterString();
            RequestPageData cachedData;

            if (this.requestCache.TryGetValue(filterString, out cachedData))
            {
                cachedData.resultTotal = page.resultTotal;

                this.requestCache[filterString] = RequestPageData.Append(cachedData,
                                                                         page.resultOffset,
                                                                         Utility.MapProfileIds(page.items));
            }
            else
            {
                cachedData = new RequestPageData()
                {
                    resultOffset = page.resultOffset,
                    resultTotal  = page.resultTotal,
                    modIds       = Utility.MapProfileIds(page.items),
                };

                this.requestCache.Add(filterString, cachedData);
            }

            // cache profiles
            this.CacheModProfiles(page.items);
        }