Esempio n. 1
0
        public async Task <IActionResult> TvgSitesAsync(CancellationToken cancellationToken = default)
        {
            var tvgSites = await _memoryCache.GetOrCreateAsync(CacheKeys.SitesKey, async entry =>
            {
                entry.SlidingExpiration = TimeSpan.FromHours(12);
                var response            = await _sitePackService.ListSitePackAsync(string.Empty, _elasticConfig.MaxResultWindow, cancellationToken);
                return(response);
            });

            return(Ok(tvgSites));
        }
Esempio n. 2
0
        public async Task <IActionResult> SitePacksAsync([FromQuery] string filter, CancellationToken cancellationToken)
        {
            var sitePacks = await _memoryCache.GetOrCreateAsync($"{CacheKeys.SitePacksKey}-{filter}", async entry =>
            {
                entry.SlidingExpiration = TimeSpan.FromHours(12);
                var response            = await _sitePackService.ListSitePackAsync(filter, cancellationToken: cancellationToken);
                return(response.Select(x => new { x.Site, x.Country }).Distinct());
            });

            return(new OkObjectResult(sitePacks));
        }