Beispiel #1
0
        public IViewComponentResult Invoke()
        {
            IExpirationTrigger trigger;
            var movies = _moviesService.GetFeaturedMovies(out trigger);

            // Add custom triggers
            EntryLinkHelpers.ContextLink.AddExpirationTriggers(new[] { trigger });

            return(View(movies));
        }
Beispiel #2
0
        public IViewComponentResult Invoke()
        {
            // Since this component is invoked from within a CacheTagHelper,
            // cache the movie list and provide an expiration trigger, which when triggered causes the
            // CacheTagHelper's cached data to be invalidated.
            var cacheKey = "featured_movies";
            IEnumerable <FeaturedMovies> movies;

            if (!_cache.TryGetValue(cacheKey, out movies))
            {
                IExpirationTrigger trigger;
                movies = _moviesService.GetFeaturedMovies(out trigger);
                _cache.Set(cacheKey, movies, new MemoryCacheEntryOptions().AddExpirationTrigger(trigger));
            }

            return(View(movies));
        }
 public IViewComponentResult Invoke()
 {
     return(View(_moviesService.GetFeaturedMovies()));
 }