Redis Dataloader wraps Facebook's DataLoader to add Redis as a distributed caching layer, enabling sharing of cache across processes/servers. Current stable version 1.0.2 (last released Nov 2019, low maintenance). Requires both Redis client (node_redis or ioredis) and DataLoader itself. Key differentiator from standard DataLoader: cross-process caching via Redis, TTL support, and async clear/prime methods. Designed for GraphQL backends needing horizontal scalability.
npm install redis-dataloaderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup: create Redis client, factory-import RedisDataLoader, create base DataLoader, then RedisDataLoader instance with prefix, batch loader, and options including TTL (expire). Demonstrates load, clear (async), and local-only clear operations.
Always await the result of clear(): await loader.clear(key);
Use a Redis SCAN or FLUSHDB manually, or implement custom batch clear.
Use prime() only when you intend to force-update the cache; otherwise avoid.
Provide serialize/deserialize in options to handle Date or other types.
Always pass { cache: false } to the base DataLoader.Use const RedisDataLoader = require('redis-dataloader')({ redis: redisClient });Clear all keys with a Redis scan + del, or use clearAllLocal() for local cache only.
Ensure RedisDataLoader is called with { redis: client }, then construct new loader with prefix, baseLoader, options.