private async Task <byte[]> GetAndRefreshAsync(string key, bool getData, CancellationToken token = default) { if (key == null) { throw new ArgumentNullException(nameof(key)); } token.ThrowIfCancellationRequested(); // This also resets the LRU status as desired. // TODO: Can this be done in one operation on the server side? Probably, the trick would just be the DateTimeOffset math. string[] results; if (getData) { results = await _redisClient.HashMGetAsync(key, AbsoluteExpirationKey, SlidingExpirationKey, DataKey); } else { results = await _redisClient.HashMGetAsync(key, AbsoluteExpirationKey, SlidingExpirationKey); } // TODO: Error handling if (results.Length >= 2) { MapMetadata(results, out DateTimeOffset? absExpr, out TimeSpan? sldExpr); await RefreshAsync(key, absExpr, sldExpr, token); } if (results.Length >= 3 && !string.IsNullOrEmpty(results[2])) { return(Encoding.UTF8.GetBytes(results[2])); } return(null); }