DataLoader<K extends Object, V, C> class
A DataLoader
creates a public API for loading data from a particular
data back-end with unique keys such as the id
column of a SQL table or
document name in a MongoDB database, given a batch loading function.
Each DataLoader
instance contains a unique memoized cache. Use caution
when used in long-lived applications or those which serve many users with
different access permissions and consider creating a new instance per
web request.
Constructors
-
DataLoader(BatchLoadFn<
K, V> _batchLoadFn, [DataLoaderOptions<K, V, C> ? options]) -
Main DataLoader constructor
use DataLoader.unmapped if the
item key
K
is equal to the cache keyC
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
K key) → DataLoader< K, V, C> -
Clears the value at
key
from the cache, if it exists. Returns itself for method chaining. -
clearAll(
) → DataLoader< K, V, C> -
Clears the entire cache. To be used when some event results in unknown
invalidations across this particular
DataLoader
. Returns itself for method chaining. -
load(
K key) → Future< V> - Loads a key, returning a Future for the value represented by that key.
-
loadMany(
List< K> keys) → Future<List< V> > - Loads multiple keys, promising an array of values:
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prime(
K key, V value) → DataLoader< K, V, C> - Adds the provided key and value to the cache. If the key already exists, no change is made. Returns itself for method chaining.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
unmapped<
K extends Object, V> (BatchLoadFn< K, V> _batchLoadFn, [DataLoaderOptions<K, V, K> ? options]) → DataLoader<K, V, K> -
Constructs a DataLoader where the
item key
K
is equal to the cache key