Reputation: 1467
I'd like to understand why memoize
is exposed through Concurrent[F]
in the Scala cats-effect library.
My intuition tells me that there should be no requirement for concurrency or fibers here and so be available for anything with Sync
. As it's not the case, I would like to understand why.
I believe memoization might need a dedicated implementation in an asynchronous environment (where the second call might occur while the first one is still running and hence need to wait for the memoized result). However, is an asynchronous environment a hard pre-requisite? Or is it simply that alternative implementation could theoretically be provided for Sync
but it has not been done (or justified) yet?
Upvotes: 1
Views: 81