Ejemplo n.º 1
0
        private async Task <string> Fetch(string url)
        {
            var cacheKey = $"{CachePrefix}:{url}";

            {
                var cachedContent = await CachingService.GetStringAsync(cacheKey);

                if (!string.IsNullOrEmpty(cachedContent))
                {
                    return(cachedContent);
                }
            }

            _bucket.Consume(1);

            var content = await FetchInternal(cacheKey, url);

            if (string.IsNullOrEmpty(content) || content.StartsWith("{\"status_code\":25"))
            {
                return(await Fetch(url));
            }

            return(content);
        }