An in-process cache with single-flight filling semantics.
In short: Given a function that computes the value to be cached for a key, it will ensure that the function is called only once per key no matter how many concurrent cache gets are issued for a key.
This might be useful if, say, you find yourself reaching for the
singleflight
package and you want to cache the resulting
values in memory.
See example_test.go for example usage.
make test
If you like this package, all credit should go to @jphines, who suggested the initial design as we were working through an in-process DNS caching mechanism.
If you don't like its design or its implementation, all blame lies with @mccutchen.