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 - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

test/ioredis.unit.js

8

gulpfile.js
const gulp = require('gulp');
const mocha = require('gulp-mocha');
gulp.task('default', () => gulp.src('test.js', { read: false }).pipe(mocha()));
gulp.task('test', () => gulp.src('test.js', { read: false }).pipe(mocha()));
gulp.task('default', () =>
gulp.src('test/**/*.unit.js', { read: false }).pipe(mocha())
);
gulp.task('test', () =>
gulp.src('test/**/*.unit.js', { read: false }).pipe(mocha())
);

@@ -5,5 +5,7 @@ const _ = require('lodash');

const stringify = require('json-stable-stringify');
const IORedis = require('ioredis');
module.exports = fig => {
const redis = fig.redis;
const isIORedis = redis instanceof IORedis;

@@ -51,6 +53,9 @@ const parse = (resp, opt) =>

multi.get(fullKey);
multi.exec(
(err, replies) =>
err ? reject(err) : parse(_.last(replies), opt).then(resolve)
);
multi.exec((err, replies) => {
const lastReply = isIORedis
? _.last(_.last(replies))
: _.last(replies);
return err ? reject(err) : parse(lastReply, opt).then(resolve);
});
})

@@ -71,6 +76,7 @@ );

_.map(keys, k => makeKey(keySpace, k, opt.cacheKeyFn)),
(err, results) =>
err
(err, results) => {
return err
? reject(err)
: Promise.map(results, r => parse(r, opt)).then(resolve)
: Promise.map(results, r => parse(r, opt)).then(resolve);
}
)

@@ -77,0 +83,0 @@ );

{
"name": "redis-dataloader",
"version": "0.4.1",
"version": "0.4.2",
"description": "DataLoader Using Redis as a Cache",

@@ -29,2 +29,3 @@ "main": "index.js",

"dataloader": "^1.2.0",
"ioredis": "^3.1.2",
"json-stable-stringify": "^1.0.1",

@@ -38,2 +39,3 @@ "lodash": "^4.17.2"

"gulp-mocha": "^3.0.1",
"ioredis": "^3.1.2",
"redis": "^2.6.3",

@@ -40,0 +42,0 @@ "sinon": "^1.17.6"

@@ -11,2 +11,5 @@ # Redis Dataloader

const redisClient = require('redis').createClient();
// the "ioredis" module is also supported
// const Redis = require('ioredis');
// const redisClient = new Redis();
const DataLoader = require('dataloader');

@@ -94,3 +97,3 @@ const RedisDataLoader = require('redis-dataloader')({ redis: redisClient });

By default, the "cacheKeyFn" will serialize objects and arrays using [json-stable-stringify](https://github.com/substack/json-stable-stringify) and allow all other values to pass through unchanged.
The `cacheKeyFn` will default to serialize objects and arrays using [json-stable-stringify](https://github.com/substack/json-stable-stringify) and allow all other values to pass through unchanged.

@@ -114,1 +117,8 @@ ### Caching

```
## Development
1. Install Dependencies `npm install`
1. Start Redis `docker-compose stop && docker-compose rm && docker-compose build && docker-compose up -d`
1. Run Tests `grunt test`
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