kgraphql / com.apurebase.kgraphql.test / SimpleDataLoaderImpl

SimpleDataLoaderImpl

open class SimpleDataLoaderImpl<K, R> : DataLoader<K, R>

Constructors

<init>

SimpleDataLoaderImpl(options: DataLoaderOptions<K, R>, batchLoader: BatchLoader<K, R>, parent: Job? = null)
SimpleDataLoaderImpl(batchLoader: BatchLoader<K, R>)
SimpleDataLoaderImpl(options: DataLoaderOptions<K, R>, statisticsCollector: StatisticsCollector, batchLoader: BatchLoader<K, R>)

Properties

options

open val options: DataLoaderOptions<K, R>

Functions

clear

Removes the value of the given Key from the cache

open suspend fun clear(key: K): Unit

clearAll

Removes all values from the cache

open suspend fun clearAll(): Unit

createStatisticsSnapshot

Returns a snapshot of the statistics at the point of calling

open suspend fun createStatisticsSnapshot(): DataLoaderStatistics

dispatch

Executes all stored requests via the given batchLoader. After this function finishes all Deferred created before are completed.

open suspend fun dispatch(): Unit

loadAsync

Loads the value for the given Key. The returned Deferred completes with the finish of dispatch in case of DataLoaderOptions.batchLoadEnabled = true. If DataLoaderOptions.batchLoadEnabled = false it calls the BatchLoader immediately and returns the retrieved value.

open suspend fun loadAsync(key: K): Deferred<R>

loadManyAsync

The same as loadAsync but for multiple Keys at once.

open suspend fun loadManyAsync(vararg keys: K): Deferred<List<R>>

prime

Primes the cache with the given values. After priming the BatchLoader will not be called with this key.

open suspend fun prime(key: K, value: R): Unit

Primes the cache with the given Throwable. After priming the BatchLoader will not be called with this key, if DataLoaderOptions.cacheExceptions = true.

open suspend fun prime(key: K, value: Throwable): Unit

Extension Functions

prime

suspend fun <K, R> SimpleDataLoaderImpl<K, R>.prime(cacheEntry: Pair<K, R>): Unit
suspend fun <K, R> SimpleDataLoaderImpl<K, R>.prime(cacheEntry: Pair<K, Throwable>): Unit

Inheritors

TimedAutoDispatcherImpl

class TimedAutoDispatcherImpl<K, R> : SimpleDataLoaderImpl<K, R>, CoroutineScope