/fillcache

A simple in-process cache with single-flight filling semantics

Primary LanguageGoMIT LicenseMIT

fillcache

Documentation Build status Code coverage Go report card

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.

Usage

See example_test.go for example usage.

Testing

make test

Credits

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.