private async Task <string> GetCachedStringAsync(string cacheKey)
        {
            if (_localCache.TryGetValue(cacheKey, out var content))
            {
                return(content);
            }

            var bytes = await _dynamicCache.GetAsync(cacheKey);

            if (bytes == null)
            {
                return(null);
            }

            return(Encoding.UTF8.GetString(bytes));
        }
        private string GetDistributedCache(string cacheKey)
        {
            string content;

            if (_cache.TryGetValue(cacheKey, out content))
            {
                return(content);
            }

            var bytes = _dynamicCache.GetAsync(cacheKey).Result;

            if (bytes == null)
            {
                return(null);
            }

            return(Encoding.UTF8.GetString(bytes));
        }
        private async Task <string> GetCachedStringAsync(string cacheKey)
        {
            if (_localCache.TryGetValue(cacheKey, out var content))
            {
                return(content);
            }

            var failover = _memoryCache.Get <bool>(FailoverKey);

            if (failover)
            {
                return(null);
            }

            try
            {
                var bytes = await _dynamicCache.GetAsync(cacheKey);

                if (bytes == null)
                {
                    return(null);
                }

                return(Encoding.UTF8.GetString(bytes));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Failed to read the '{CacheKey}' from the dynamic cache", cacheKey);

                _memoryCache.Set(FailoverKey, true, new MemoryCacheEntryOptions()
                {
                    AbsoluteExpirationRelativeToNow = _dynamicCacheOptions.FailoverRetryLatency
                });
            }

            return(null);
        }