abstract class RefreshRef[F[_], V] extends AnyRef
- Alphabetic
- By Inheritance
- RefreshRef
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new RefreshRef()
Abstract Value Members
- abstract def cancel: F[Boolean]
Cancel polling and remove data from memory
Cancel polling and remove data from memory
- returns
true if there was data and polling, false if it's empty
- abstract def get(period: FiniteDuration, staleTimeoutO: Option[FiniteDuration])(fetch: F[V])(errorHandler: PartialFunction[Throwable, F[Unit]]): F[V]
- Attributes
- protected
- abstract def get: F[Option[V]]
Simply gets the data from memory
Simply gets the data from memory
- returns
Some(v) if exists, None if not
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getOrFetch(period: FiniteDuration, staleTimeout: FiniteDuration)(fetch: F[V])(errorHandler: PartialFunction[Throwable, F[Unit]]): F[V]
Like
getOrFetch(period: FiniteDuration)(fetch: F[V])
but with added resilency against failures infetch
.Like
getOrFetch(period: FiniteDuration)(fetch: F[V])
but with added resilency against failures infetch
.After
staleTimeout
of continuous polling failures, the polling will stop and data removed. A successfetch
resets the timer.- period
if set to zero will simply return
fetch
- staleTimeout
timeout after the last successful
fetch
RepeatingSuite.scala
- def getOrFetch(period: FiniteDuration)(fetch: F[V]): F[V]
Either gets the data from the memory if available, or use the
fetch
to retrieve the data, and setup a polling everyperiod
to update the data in memory usingfetch
.Either gets the data from the memory if available, or use the
fetch
to retrieve the data, and setup a polling everyperiod
to update the data in memory usingfetch
. Hence the first call toref.getOrFetch
will take longer to actually load the data from upstream to memory. Subsequent call will always return the data from memory.When any exception occurs during
getDataFromUpstream
, the refresh stops, and the data is removed from the memory. All subsequent requests will incure effect infetch
, whose failure will be surfaced, until it succeeds.- period
if set to zero will simply return
fetch
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])