Ejemplo n.º 1
0
        public async Task <List <Work> > Works()
        {
            var webDocument = await _client.GetWorks();

            _cache.GetOrCreate("WorksCache", entry =>
            {
                entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(15);
                entry.SetPriority(CacheItemPriority.High);
                return(WorkAdapter.ExtractWorks(webDocument));
            });
            return(WorkAdapter.ExtractWorks(webDocument));
        }
Ejemplo n.º 2
0
        public async Task <List <Work> > Search(SearchRequest request)
        {
            var searchPattern = request.Query is null ? "" : Regex.Replace(request.Query, @"\s+|\,+", "+");

            searchPattern += string.IsNullOrEmpty(request.Page) ? "&page=1" : $"&page={request.Page}";
            var webDocument = await _client.GetWorks(searchPattern);

            var works = WorkAdapter.ExtractWorks(webDocument);

            _cache.GetOrCreate("WorksCache", entry =>
            {
                entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(15);
                entry.SetPriority(CacheItemPriority.High);
                return(works);
            });
            return(works);
        }