4 ms·
Because the computation of Result is _expensive_ and _async_. So if you get two requests for the computation that computes Result in close succession the Map d
by Marazan 4y ago
Because the computation of Result is _expensive_ and _async_.
So if you get two requests for the computation that computes Result in close succession the Map doesn't have the result in place for the second call and as a result you get no caching effect and make 2 expensive requests.
By caching the Promise instead the second request is caught by the cache and simply awaits the Promise resolving so now you only get 1 expensive request.