Fix cache fo getstatus too.
MODIFY
WalletWasabi.Backend/Controllers/BlockchainController.cs
WalletWasabi.Backend/Controllers/BlockchainController.cs
@@ -419,9 +419,25 @@ namespace WalletWasabi.Backend.Controllers
{
var cacheKey = $"{nameof(GetStatusAsync)}";
- if (!Cache.TryGetValue(cacheKey, out StatusResponse status))
+ return await Cache.AtomicGetOrCreateAsync(
+ cacheKey,
+ entry =>
+ {
+ entry.SetAbsoluteExpiration(TimeSpan.FromSeconds(30));
+
+ return FetchStatusAsync();
+ });
+ }
+ catch (Exception ex)
+ {
+ Logger.LogDebug(ex);
+ throw ex;
+ }
+ }
+
+ private async Task<StatusResponse> FetchStatusAsync()
{
- status = new StatusResponse();
+ StatusResponse status = new StatusResponse();
// Updating the status of the filters.
if (DateTimeOffset.UtcNow - Global.IndexBuilderService.LastFilterBuildTime > FilterTimeout)
@@ -453,18 +469,8 @@ namespace WalletWasabi.Backend.Controllers
{
status.CoinJoinCreationActive = true;
}
- var cacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(30));
-
- Cache.Set(cacheKey, status, cacheEntryOptions);
- }
return status;
}
- catch (Exception ex)
- {
- Logger.LogDebug(ex);
- throw ex;
- }
- }
}
}

Fix cache fo getstatus too.