Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis-dataloader

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-dataloader

DataLoader Using Redis as a Cache

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.1K
increased by33.89%
Maintainers
1
Weekly downloads
 
Created
Source

Redis Dataloader

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)
  • dataloader results must be either null or a JSON object.

Keywords

FAQs

Package last updated on 04 Dec 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc