Esempio n. 1
0
        private static PetOwnerList GetPetOwnerListInner(Guid providerGroupId)
        {
            // Step 1. Get List
            PetOwnerList result = new GetPetOwnerList()
            {
                ProviderGroupId = providerGroupId
            }.ExecuteList();

            // Step 2. Check for the context
            HttpContext httpContext = HttpContext.Current;

            if (httpContext != null)
            {
                // Active Dependency
                CacheDependency cacheDependency = new CacheDependency(null, new string[] { GetActiveProviderGroupCacheKey(providerGroupId) });

                httpContext.Cache.Insert(GetPetOwnerListCacheKey(providerGroupId), result, null, DateTime.Now.AddSeconds(GetPetLinkListExpirationInSeconds()), Cache.NoSlidingExpiration, PetOwnerListCacheItemUpdateCallbackMethod);
            }

            return(result);
        }
Esempio n. 2
0
        public static void PetOwnerListCacheItemUpdateCallbackMethod(string key, CacheItemUpdateReason reason, out object expensiveObject, out CacheDependency dependency, out DateTime absoluteExpiration, out TimeSpan slidingExpiration)
        {
            // Step 0.
            expensiveObject    = null;
            dependency         = null;
            absoluteExpiration = DateTime.Now.AddSeconds(GetPetLinkListExpirationInSeconds());
            slidingExpiration  = Cache.NoSlidingExpiration;

            if (DateTime.Now.Minute % 10 == 0)
            {
                return; // do nothing
            }

            // Step 1. Parse Key
            Guid?providerGroupId = GetPetOwnerListCacheKeyProviderGroupId(key);

            if (providerGroupId != null)
            {
                expensiveObject = new GetPetOwnerList()
                {
                    ProviderGroupId = providerGroupId.Value
                }.ExecuteList();
            }
        }