public async Task<IActionResult> GetR(int id) { if (_cache.TryGetValue($"normal{id}", out var value)) { _logger.LogDebug($"Take from cache for pin:{id} value:{value}"); return Ok(value); } var answer = await _toArduino.SendQuery($"/digital/{id}/r"); if (answer.Length == 1) { _cache.Set($"normal{id}", answer, CacheEntryOptions); return Ok(answer); } _logger.LogDebug($"Exception to get value for pin:{id} set:0"); return Ok("0"); }
public async Task <IActionResult> GetR(int id) { if (_cache.TryGetValue($"revers{id}", out var value)) { _logger.LogDebug($"Take from cache for pin:{id} value:{value}"); return(Ok(value)); } var answer = await _toArduino.SendQuery($"/digital/{id}/r"); if (answer.Length == 1) { var newval = ReturnRevertVal(Convert.ToInt16(answer)); _cache.Set($"revers{id}", newval, CacheEntryOptions); return(Ok(newval)); } _logger.LogDebug($"Exception to get value for pin:{id} set:0"); return(Ok("0")); }