core.io-cache-redis
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -65,7 +65,9 @@ const extend = require('gextend'); | ||
const useCache = hasCacheKeys(getKeys); | ||
/** | ||
* Query the keys that passed | ||
* shouldQueryCache: | ||
* If we have any non-null keys | ||
* then get them from cache | ||
*/ | ||
if (hasCacheKeys(getKeys)) { | ||
if (useCache) { | ||
cachedValues = await this.getBatch(getKeys, [], options); | ||
@@ -76,3 +78,3 @@ } | ||
* If all keys were found in | ||
* the cache. Return values... | ||
* the cache return values. | ||
*/ | ||
@@ -101,3 +103,3 @@ if (notEmpty(cachedValues) === rawKeys.length) { | ||
const fetchKeys = hasCacheKeys(getKeys) ? batchKeys : rawKeys; | ||
const fetchKeys = useCache ? batchKeys : rawKeys; | ||
@@ -143,3 +145,7 @@ try { | ||
if (hasCacheKeys(getKeys)) { | ||
if (useCache) { | ||
/** | ||
* Combine cached values and | ||
* fetched values for our result. | ||
*/ | ||
fetchKeys.forEach((key, index) => { | ||
@@ -151,2 +157,7 @@ const cachedIndex = values[key]; | ||
} else { | ||
/** | ||
* If we didn't hit the cache | ||
* fetchKeys should be all | ||
* original keys. | ||
*/ | ||
values = results; | ||
@@ -214,4 +225,8 @@ } | ||
setBatch(keys, values, o = {}) { | ||
if (notValidArguments(keys, values)) { | ||
throw new CacheClientError('Argument error', 400); | ||
throw new CacheClientError( | ||
getMessage(keys, values, 'Argument error'), | ||
400 | ||
); | ||
} | ||
@@ -224,3 +239,3 @@ | ||
keys = this.hashKeyBatch(keys); | ||
keys = this.hashKeyBatch(keys, o); | ||
@@ -273,2 +288,6 @@ const tx = this.client.multi(); | ||
return a.filter(a => a != null).length; | ||
} | ||
function getMessage(keys, values, msg) { | ||
return `${msg}: keys ${keys.length} values ${values.length}`; | ||
} |
{ | ||
"name": "core.io-cache-redis", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "Redis cache module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
31244
14
744