public void RemoveCachedItem(CacheKeys CacheKeyName)
 {
     if (MainCache.Contains(CacheKeyName.ToString()))
     {
         MainCache.Remove(CacheKeyName.ToString());
     }
 }
        public object GetCachedItem(CacheKeys CacheKeyName)
        {
            lock (_lock)
            {
                if (!MainCache.Contains(CacheKeyName.ToString()))
                {
                    switch (CacheKeyName)
                    {
                    case CacheKeys.Settings:
                        var setting = SettingService.Queryable().FirstOrDefault();
                        UpdateCache(CacheKeys.Settings, setting);
                        break;

                    case CacheKeys.SettingDictionary:
                        var settingDictionary = SettingDictionaryService.Queryable().ToList();
                        UpdateCache(CacheKeys.SettingDictionary, settingDictionary);
                        break;

                    case CacheKeys.Categories:
                        var categories = CategoryService.Queryable().Where(x => x.Enabled).OrderBy(x => x.Ordering).ToList();
                        UpdateCache(CacheKeys.Categories, categories);
                        break;

                    case CacheKeys.ListingTypes:
                        var ListingTypes = ListingTypeService.Query().Include(x => x.CategoryListingTypes).Select().ToList();
                        UpdateCache(CacheKeys.ListingTypes, ListingTypes);
                        break;

                    case CacheKeys.ContentPages:
                        var contentPages = ContentPageService.Queryable().Where(x => x.Published).OrderBy(x => x.Ordering).ToList();
                        UpdateCache(CacheKeys.ContentPages, contentPages);
                        break;

                    case CacheKeys.EmailTemplates:
                        var emailTemplates = EmailTemplateService.Queryable().ToList();
                        UpdateCache(CacheKeys.EmailTemplates, emailTemplates);
                        break;

                    case CacheKeys.Statistics:
                        SaveCategoryStats();

                        var statistics = new Statistics();
                        statistics.CategoryStats = CategoryStatService.Query().Include(x => x.Category).Select().ToList();

                        statistics.ListingCount     = ListingService.Queryable().Count();
                        statistics.UserCount        = AspNetUserService.Queryable().Count();
                        statistics.OrderCount       = OrderService.Queryable().Count();
                        statistics.TransactionCount = 0;

                        statistics.ItemsCountDictionary = ListingService.GetItemsCount(DateTime.Now.AddDays(-10));

                        UpdateCache(CacheKeys.Statistics, statistics);
                        break;

                    default:
                        break;
                    }
                }
                ;

                return(MainCache[CacheKeyName.ToString()] as Object);
            }
        }