> In addition the pf should execute elsewhere. We want putIfAbsent to return asap as the pf body could take some time in general terms - not particularly in our use-case, but I think it is nice to be general.

If you want it to be general, then you're doing it right. My comment is just that it maybe doesn't need to be general. :)

> Given that the future is determined only when there wasn't a previous key, we need therefore to retain promises in the map.

You only need to store a Promise if you want to set a value that you didn't put in. I'll talk you through my suggested code offline.