Skip to content

Commit

Permalink
Use sync Wait and running sync
Browse files Browse the repository at this point in the history
  • Loading branch information
heaths committed May 15, 2020
1 parent f1b4f7f commit fd7697d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ internal async ValueTask<Response> GetOrAddAsync(bool isAsync, string uri, TimeS
return await cachedResponse.CloneAsync(isAsync);
}

await _lock.WaitAsync().ConfigureAwait(false);
if (isAsync)
{
await _lock.WaitAsync().ConfigureAwait(false);
}
else
{
_lock.Wait();
}

try
{
// Try again to get a valid cached response inside the lock before fetching.
Expand Down

0 comments on commit fd7697d

Please sign in to comment.