Beispiel #1
0
        public static async Task <List <JGN_Videos> > LoadItems(ApplicationDbContext context, VideoEntity entity)
        {
            if (!entity.iscache ||
                Jugnoon.Settings.Configs.GeneralSettings.cache_duration == 0 ||
                entity.pagenumber > Jugnoon.Settings.Configs.GeneralSettings.max_cache_pages)
            {
                return(await Load_Raw(context, entity));
            }
            else
            {
                string key  = VideoBLL.GenerateKey("lg_video_cat_", entity);
                var    data = new List <JGN_Videos>();
                if (!SiteConfig.Cache.TryGetValue(key, out data))
                {
                    data = await Load_Raw(context, entity);

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            // Keep in cache for this time, reset time if accessed.
                                            .SetSlidingExpiration(TimeSpan.FromSeconds(3600));

                    // Save data in cache.
                    SiteConfig.Cache.Set(key, data, cacheEntryOptions);
                }
                else
                {
                    data = (List <JGN_Videos>)SiteConfig.Cache.Get(key);
                }
                return(data);
            }
        }