Refreshable

Companion:
class
Source:
Refreshable.scala
class Object
trait Matchable
class Any

Type members

Classlikes

sealed abstract class RefreshableBuilder[F[_], A]

Caches a single instance of type A for a period of time before refreshing it automatically.

Caches a single instance of type A for a period of time before refreshing it automatically.

The time between refreshes is dynamic and based on the value of each A itself. This is similar to RefreshableEffect except that only exposes a fixed refresh frequency.

As well as the time between refreshes, the retry policy is also dynamic and based on the value for A. This allows you to configure the policy based on when A is going to expire.

You can use the cacheDuration and retryPolicy together to eagerly fetch a new value for A using the calculated cache duration minus some duration to allow for retries and then set the retry policy to retry throughout that duration.

An old value is only made unavailable after a new value has been acquired. This means that the time each value is exposed for is cacheDuration plus the time to evaluate fa.

Value parameters:
cacheDuration

how long to cache a newly generated value of A for, if an effect is needed to generate this duration it should have occurred in fa. Defaults to defaultCacheDuration if not specified.

combineFunction

a function which takes the old value and new value, returning some effectful value. This can be used to perform actions like accumulation of the underlying values or discarding new values that don't match some predicate. A failure in the returned F[A] will result in the value not being updated, now will it trigger the refreshFailureCallback as a failure in this function is nothing to do with the internals of Refreshable and should be handled properly by the caller, however the value in the store will be set to a CachedValue.Error

defaultValue

an optional default value to use when initialising the resource, if the call to fa fails. This will prevent the constructor from failing during startup

exhaustedRetriesCallback

what to do if retrying to refresh the value fails. The refresh fiber will have failed at this point and the value will grow stale. It is up to user handle this failure, as they see fit, in their application

newValueCallback

a callback invoked whenever a new value is generated, the scala.concurrent.duration.FiniteDuration is the period that will be waited before the next new value

refresh

generate a new value of A

refreshFailureCallback

what to when an attempt to refresh the value fails, fa will be retried according to retryPolicy

retryPolicy

a function to derive a configuration object for attempting to retry the effect of fa on failure from the current value of A. Defaults to defaultRetryPolicy when not specified

Source:
Refreshable.scala

Value members

Concrete methods

def builder[F[_] : Temporal, A](refresh: F[A]): RefreshableBuilder[F, A]

Builder to construct a Refreshable

Builder to construct a Refreshable

Source:
Refreshable.scala
def defaultCacheDuration[A]: A => FiniteDuration
def defaultPolicy[F[_] : Applicative]: RetryPolicy[F]

The default retry policy used when none is specified.

The default retry policy used when none is specified.

Source:
Refreshable.scala