News for hackers. Stuff that matters.
Re:Ask HN: What are some cool but obscure data structures yo... by lolinder on Friday July 22, 2022 @09:47AM (#32191820)
This is a great solution to the thundering herd problem, but isn't OP explicitly trying to cache the results for later? In that case, the promise map is a clever way to make sure the cachable value is fetched at most once, and you want the keys to build up in the map, so GC'ing them is counterproductive.
Re:Ask HN: What are some cool but obscure data structures yo... by ralusek on Friday July 22, 2022 @11:03AM (#32192649)
Ya it obviously depends on the intended goal, but caching items in a map indefinitely better be done on a set of values that is known to be limited to a certain size over the lifetime of the server or it'll lead to a memory leak.
Re:Ask HN: What are some cool but obscure data structures yo... by kevinforrestcon on Friday July 22, 2022 @01:24PM (#32194581)
If the result of the async function is not necessarily the same value every time you call it, you may want to recompute it