Skip to content

Commit 673ebec

Browse files
author
Scott Taylor
committed
Added updating higher priority caches with results if found in lower caches
1 parent deeddaf commit 673ebec

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/multi_caching.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ var multiCaching = function(caches, options) {
9696
/**
9797
* Then put back the options in the args Array
9898
*/
99-
args.push(options);
10099

101100
if (multi) {
102101
/**
@@ -120,7 +119,7 @@ var multiCaching = function(caches, options) {
120119
var _isCacheableValue = getIsCacheableValueFunction(cache);
121120

122121
if (multi) {
123-
addResultToMap(result, _isCacheableValue);
122+
addResultToMap(result, _isCacheableValue, i);
124123

125124
if (keysToFetch.length === 0 || i === caches.length - 1) {
126125
// Return an Array with the values merged from all the caches
@@ -155,7 +154,7 @@ var multiCaching = function(caches, options) {
155154
return cb(err, result);
156155
});
157156

158-
function addResultToMap(result, isCacheable) {
157+
function addResultToMap(result, isCacheable, cacheIndex) {
159158
var key;
160159
var diff = 0;
161160

@@ -171,6 +170,10 @@ var multiCaching = function(caches, options) {
171170
// Add the result to our map
172171
mapResult[key] = res;
173172

173+
for (let j = 0; j < cacheIndex; j++ ) {
174+
caches[j].store.set(key, res);
175+
}
176+
174177
// delete key from our keysToFetch array
175178
keysToFetch.splice(i - diff, 1);
176179
diff += 1;

0 commit comments

Comments
 (0)