build

inline fun <K, V, K1 : K, V1 : V> CacheBuilder<K, V>.build(noinline loader: (key: K1) -> V1): LoadingCache<K1, V1>(source)

Builds a cache, which either returns an already-loaded value for a given key or atomically computes or retrieves it using the supplied loader. If another thread is currently loading the value for this key, simply waits for that thread to finish and returns its loaded value. Note that multiple threads can concurrently load values for distinct keys.

This method does not alter the state of this CacheBuilder instance, so it can be invoked again to create multiple independent caches.

Return

a cache having the requested features

Parameters

loader

the cache loader used to obtain new values