public async Task <IResponse> RequestAsync(IRequest request, CancellationToken cancel)
        {
            try
            {
                if ((await _cacheClient.SearchKeysAsync(request.Address.Href)).Count() != 0)
                {
                    _logger.LogInformation($"Cache hit for: {request.Address.Href}");
                    return(await _cacheClient.GetAsync <CachedResponse>(request.Address.Href));
                }

                _logger.LogInformation($"Cache miss for: {request.Address.Href}");

                _logger.LogInformation($"requesting: {request.Address.Href}");
                Response response = (Response)await _innerRequestor.RequestAsync(request, cancel);

                _logger.LogInformation($"response recieved from: {request.Address.Href}");
                var cachedRequest = new CachedResponse(response);
                _logger.LogInformation($"caching entry: {request.Address.Href}");
                await _cacheClient.AddAsync(request.Address.Href, cachedRequest);

                return(cachedRequest);
            }
            catch (Exception ex) {
                throw;
            }
        }
        //dentro del parametro task<Modelo> o objeto a devolver por la acion.


        public async Task <T> Get()
        {
            try
            {
                return(await redis.GetAsync <T>(key));
            }
            catch (Exception ex)
            {
                throw new RepositoryException("Error con redis", ex);
                throw;
            }
        }
 public Task <object> GetAsync(string key) => Client.GetAsync <object>(key);
Beispiel #4
0
 public Task <T> GetAsync <T>(string key) where T : class
 {
     return(_retryPolicy.ExecuteAsync(() => _cacheClient.GetAsync <T>(key)));
 }
Beispiel #5
0
 public async Task <T> Get <T>(string key)
 {
     return(await cacheClient.GetAsync <T>(key));
 }
 public async Task <Notification> GetNotification()
 {
     return(await _cache.GetAsync <Notification>(_cacheKey));
 }