@bodyam8/core
Version:
most useful backend tools
34 lines (21 loc) • 1.01 kB
Markdown
### Dataloaders
___
[Dataloaders repo](https://github.com/graphql/dataloader)
Originally dataloaders are used to batch and cache
requests. Dataloaders have in-memory cache, that can
be disabled via options.
**Our implementation also let
dataloaders to have a redis cache.**
Batching is a mechanism, that helps us to avoid multiple
requests to database, replacing it with one big request.
Simple batching schema:

### IMPORTANT
Cache key is build as `dataloaders-${function name}-${key}`.
That's why dataloaders batch function __must__ have unique function name.
Caching mechanism has configurable `REDIS_CLIENT_MAX_CONCURRENCY` parameter
it's default values is `20`
### LOADER TYPES:
`createLoader` - loader for main tables, supports local cache
`createShardedLoader` - loader for sharded tables, cache is disabled
`createCachedLoader` - loader for main tables, cache inside redis