
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
redis-dataloader
Advanced tools
Batching and Caching layer based on the Facebook Dataloader API.
const redis = require('redis').createClient();
const DataLoader = require('dataloader');
const RedisDataLoader = require('redis-dataloader')({ redis: redis });
const redisDataLoader = new RedisDataLoader(
// set a prefix for the keys stored in redis. This way you can avoid key
// collisions for different data-sets in your redis instance.
'redis-key-prefix',
// create a regular dataloader. This should always be set with caching disabled.
new DataLoader(myBatchLoadFunction, { cache: false }),
// The options here are the same as the regular dataloader options, with
// the additional option "expire"
{
// caching here is a local in memory cache
cache: true,
// if set redis keys will be set to expire after this many seconds
// this may be useful as a fallback for a redis cache.
expire: 60
}
);
In general, RedisDataLoader has the same API as the Facebook Dataloader Api, with a few differences.
clear
returns a promise (waits until redis succeeds at deleting the key)clearAll
is not available (redis does not have an efficient way to do this?)prime
will always overwrite the redis cache. It in turn calls prime on the local cache (which does not adjust the cache if the key already exists)null
or a JSON object.FAQs
DataLoader Using Redis as a Cache
The npm package redis-dataloader receives a total of 3,557 weekly downloads. As such, redis-dataloader popularity was classified as popular.
We found that redis-dataloader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.