Ejemplo n.º 1
0
        public static void ProcessScheduleRuleAction(CacheBehavior cacheBehavior, CacheAction cacheAction)
        {
            // Step 1. Get cache key
            string cacheKey = cacheBehavior.GetCacheKey(cacheAction.Item);

            // Step 2. Get cache value
            CacheListContainer <ScheduleRule> scheduleRuleListContainer = CacheHelper2.GetCacheValue <CacheListContainer <ScheduleRule> >(cacheKey);

            if (scheduleRuleListContainer == null)
            {
                return;
            }

            // Step 3. Process
            if (cacheAction.CacheActionType == CacheActionTypes.Insert)
            {
                scheduleRuleListContainer.Put((ScheduleRule)cacheAction.Item);
            }
            else if (cacheAction.CacheActionType == CacheActionTypes.Update)
            {
                scheduleRuleListContainer.Put((ScheduleRule)cacheAction.Item);
            }
            else if (cacheAction.CacheActionType == CacheActionTypes.Delete)
            {
                scheduleRuleListContainer.Delete(((ScheduleRule)cacheAction.Item).Id);
            }
        }
Ejemplo n.º 2
0
        public virtual bool AddItem <T>(T item) where T : class, IId
        {
            // Step 1. Get Cache
            Cache cache = CacheHelper2.GetCache();

            if (cache == null)
            {
                return(false);
            }

            // Step 2.
            string cacheKey = this.GetCacheKey(item);

            // Step 3.
            switch (this.CacheType)
            {
            case CacheTypes.Item:
                var itemContainer = CacheHelper2.GetCacheValue <CacheItemContainer <T> >(cacheKey);
                itemContainer.Refresh();
                break;

            case CacheTypes.ItemList:
                var listContainer = CacheHelper2.GetCacheValue <CacheListContainer <T> >(cacheKey);
                listContainer.Put(item);
                break;
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static void ProcessProviderAction(CacheBehavior cacheBehavior, CacheAction cacheAction)
        {
            // Step 1. Get cache key
            string cacheKey = cacheBehavior.GetCacheKey(cacheAction.Item);

            // Step 2. Get cache value
            CacheItemContainer <Provider> providerContainer = CacheHelper2.GetCacheValue <CacheItemContainer <Provider> >(cacheKey);

            if (providerContainer == null)
            {
                return;
            }

            // Step 3. Refresh
            Provider provider = new GetProvider()
            {
                Id = providerContainer.Item.Id
            }.ExecuteItem(false);

            providerContainer.Item = provider;
        }