tock / ai.tock.shared.cache / getOrCache

getOrCache

fun <T : Any> getOrCache(id: Id<T>, type: String, valueProvider: () -> T?): T? (source)

Returns the value for specified id and type. If no value exists, valueProvider provides the value to cache. If valueProvider throws exception or returns null, no value is cached and null is returned.