async-cache-dedupe
Advanced tools
Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "async-cache-dedupe", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "An async deduping cache", | ||
@@ -8,3 +8,4 @@ "main": "index.js", | ||
"test": "standard | snazzy && tap test/*test.js", | ||
"lint:fix": "standard --fix" | ||
"lint:fix": "standard --fix", | ||
"redis": "docker run --rm -p 6379:6379 redis redis-server" | ||
}, | ||
@@ -11,0 +12,0 @@ "repository": { |
@@ -179,3 +179,3 @@ # async-cache-dedupe | ||
See [mercurius-cache-example](https://github.com/mercurius/mercurius-cache-example) for a complete example. | ||
See [mercurius-cache-example](https://github.com/mercurius-js/mercurius-cache-example) for a complete example. | ||
@@ -182,0 +182,0 @@ ### Redis |
@@ -211,14 +211,18 @@ 'use strict' | ||
add (args) { | ||
const key = this.getKey(args) | ||
try { | ||
const key = this.getKey(args) | ||
let query = this.dedupes.get(key) | ||
if (!query) { | ||
query = new Query() | ||
this.buildPromise(query, args, key) | ||
this.dedupes.set(key, query) | ||
} else { | ||
this.onDedupe(key) | ||
let query = this.dedupes.get(key) | ||
if (!query) { | ||
query = new Query() | ||
this.buildPromise(query, args, key) | ||
this.dedupes.set(key, query) | ||
} else { | ||
this.onDedupe(key) | ||
} | ||
return query.promise | ||
} catch (err) { | ||
this.onError(err) | ||
} | ||
return query.promise | ||
} | ||
@@ -225,0 +229,0 @@ |
@@ -583,1 +583,16 @@ 'use strict' | ||
}) | ||
test('should call onError when serialize throws exception', async (t) => { | ||
t.plan(1) | ||
const serialize = () => { | ||
throw new Error('error serializing') | ||
} | ||
const onError = err => t.equal(err.message, 'error serializing') | ||
const cache = new Cache({ storage: createStorage(), onError }) | ||
cache.define('serializeWithError', { serialize }, async k => k) | ||
await cache.serializeWithError(1) | ||
}) |
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
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
142682
3453