redis-dataloader
Advanced tools
Comparing version 0.4.1 to 0.4.2
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()) | ||
); |
20
index.js
@@ -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` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24361
11
462
122
5
7
+ Addedioredis@^3.1.2
+ Addedcluster-key-slot@1.1.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddenque@1.5.1(transitive)
+ Addedflexbuffer@0.0.6(transitive)
+ Addedioredis@3.2.2(transitive)
+ Addedlodash.assign@4.2.0(transitive)
+ Addedlodash.bind@4.2.1(transitive)
+ Addedlodash.clone@4.5.0(transitive)
+ Addedlodash.clonedeep@4.5.0(transitive)
+ Addedlodash.defaults@4.2.0(transitive)
+ Addedlodash.difference@4.5.0(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.foreach@4.5.0(transitive)
+ Addedlodash.isempty@4.4.0(transitive)
+ Addedlodash.keys@4.2.0(transitive)
+ Addedlodash.noop@3.0.1(transitive)
+ Addedlodash.partial@4.2.1(transitive)
+ Addedlodash.pick@4.4.0(transitive)
+ Addedlodash.sample@4.2.1(transitive)
+ Addedlodash.shuffle@4.2.0(transitive)
+ Addedlodash.values@4.3.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addedredis-commands@1.7.0(transitive)
+ Addedredis-parser@2.6.0(transitive)