WorkCache

spice.util.WorkCache
trait WorkCache[Key, Result]

WorkCache effectively operates on a Key to guarantee that two jobs for the same Key are not concurrently processed and additional checks on the Key will wait for the same result.

Type parameters

Key

the key tied to the work

Result

the result of the work

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

protected def persisted(key: Key): IO[Option[Result]]

Check for a persisted result. Work that is completed by work should persist to be able to be retrieved by this call.

Check for a persisted result. Work that is completed by work should persist to be able to be retrieved by this call.

Value parameters

key

the Key to look up

Attributes

Returns

Some(result) if the work has already been done for this key, None otherwise to say that the work should be done.

protected def work(key: Key): IO[WorkResult[Result]]

Execute the work to generate the Result for this Key. The contract of this method is to persist the result so that it may be retrieved by the persisted method.

Execute the work to generate the Result for this Key. The contract of this method is to persist the result so that it may be retrieved by the persisted method.

Value parameters

key

the Key to do work for

Attributes

Returns

the Result of the work

Concrete methods

def apply(key: Key): IO[Result]

Retrieve the Result for this Key doing work if necessary and retrieving from persisted state if available.

Retrieve the Result for this Key doing work if necessary and retrieving from persisted state if available.

Attributes

protected def errorHandler(key: Key, throwable: Throwable): Result