placeholder

Kached properties

Maintained by Dynatrace

You can simply say "cache the result of a function for 5 minutes" by writing:

val activeSatellites by cachedLazyFor(Duration.ofMinutes(5), {
    fetchActiveSatellites()
})

There are two delegated property builders available, depending on your business needs:

  • cachedLazyFor - once the cached value expires, a request for value returns last known value and starts updating it in the background. If needed, you can customize java.util.concurrent.Executor used to refresh the value, which defaults to Executors.newCachedThreadPool()
  • cachedBlockingFor - once the cached value expires, a request for value first updates the value in a blocking way, and then returns it