
13 Jun
2014
13 Jun
'14
1:16 p.m.
Hi Dan,
1. Create an empty cache with newCache 2. fetch repeatedly from the cache, each time providing a fallback in case it is empty.
Fetching from a Cache is thread safe: only one "fallback" will execute at a time, and after the first successful fallback, the cached value will be set and no other fallbacks will be called.
I'm not sure whether I get this correctly. If multiple threads fetch values from one cache, will only one of those threads run at a time? Or will those that fetch pairwise different values still run concurrently? In other words, does the cache have a global lock or is there a lock per value? Best regards, Peter