private async Task <bool> UpdateOnceFromWebService(bool alreadyUpdatedFromWS) { if (!alreadyUpdatedFromWS) { await _coinService.Get(); alreadyUpdatedFromWS = true; } return(alreadyUpdatedFromWS); }
public async Task <ContentResult> Get( [FromServices] IConfiguration config, [FromServices] IMemoryCache cache) { string valorJSON = await cache.GetOrCreateAsync <string>( "Cotacoes", async context => { context.SetAbsoluteExpiration(TimeSpan.FromSeconds(20)); context.SetPriority(CacheItemPriority.High); var result = await _service.Get(); return(result); }); return(Content(valorJSON, "application/json")); }