Expand description

Batch and cache database queries or other potentially expensive data lookups. The main motivation for this library is to solve the “N + 1” query problem seen in GraphQL and elsewhere. This library takes heavy influence from the GraphQL Foundation’s DataLoader.

The most common entrypoints to this library are the Batcher type (used to queue and load data in batches) and the Fetcher trait (used by Batchers to actually retrieve the data).


Used to batch and cache loads from some datastore. A Batcher can be used with any type that implements Fetcher. Batchers are asynchronous, and designed to be passed and shared between threads or tasks. Cloning a Batcher is shallow and can be used to use the same Fetcher across multiple threads or tasks.

Used to configure a new Batcher. A BatcherBuilder is returned from Batcher::build.

Holds the results of loading a batch of data from a Fetcher. Implementors of Fetcher should call insert for each value that was loaded in a batch request.


Error indicating that loading one or more values from a Batcher failed.


A trait for fetching values from some datastore in bulk. A Fetcher will be given an array of keys and should insert fetched values into a given cache. Implementing Fetcher will allow queries to be batch using a Batcher. See the Batcher docs for details about batching, caching, and error semantics.