Feature request: Functions.memoize(Function) #489
Original comment posted by pimlottc on 2012-04-03 at 03:19 PM
In light of the changes to MapMaker.makeComputerMap, I think this issue should be revisited.
The original suggestion:
is now deprecated.
Naively following the MapMaker Migration Guide suggests:
But this does not work as expected, as get() on the map view does not trigger cache loads.
Original comment posted by wasserman.louis on 2012-04-03 at 03:26 PM
Hmmmm. That suggests two options:
You can get the original behavior with "CacheBuilder.newBuilder().build(CacheLoader.from(someFunction)," as LoadingCache implements Function.
This is still messier than the original, but Function isn't typically used for heavyweight operations, so a little verbosity is probably OK for the cases in which it is.