cacheService.js
function checkCacheResponse(key, err, result, type, cacheIndex){
    if(err){
      log(true, 'Error when getting key ' + key + ' from cache of type ' + type + ':', err);

      if(cacheIndex < self.caches.length - 1){
        return {status:'continue'};
      }
    }
    //THIS ALLOWS false AS A VALID CACHE VALUE, BUT DO I WANT null TO BE VALID AS WELL?
    if(result !== null && typeof result !== 'undefined'){
      log(false, 'Key found:', {key: key, value: result});
      return {status: 'break', result: result};
    }
    var curCache = self.caches[cacheIndex];
    for(var i = cacheIndex + 1; i < self.cachesLength; i++) {
      var nextCache = self.caches[i];
      if(nextCache.checkOnPreviousEmpty || nextCache.expiration > curCache.expiration){
        return {status:'continue', toIndex: i};
      }
    }
    return {status: 'else'};
  }
function checkCacheResponse(key, err, result, type, cacheIndex){
    if(err){
      log(true, 'Error when getting key ' + key + ' from cache of type ' + type + ':', err);

      if(cacheIndex < self.caches.length - 1){
        return {status:'continue'};
      }
    }
    //THIS ALLOWS false AS A VALID CACHE VALUE, BUT DO I WANT null TO BE VALID AS WELL?
    if(result !== null && typeof result !== 'undefined'){
      log(false, 'Key found:', {key: key, value: result});
      return {status: 'break', result: result};
    }
    var curCache = self.caches[cacheIndex];
    for(var i = cacheIndex + 1; i < self.cachesLength; i++) {
      var nextCache = self.caches[i];
      if(nextCache.checkOnPreviousEmpty || nextCache.expiration > curCache.expiration){
        return {status:'continue', toIndex: i};
      }
    }
    return {status: 'else'};
  }
function checkCacheResponse ( key , err , result , type , cacheIndex ) { if ( err ) { log ( true , 'Error when getting key ' + key + ' from cache of type ' + type + ':' , err ) ; if ( cacheIndex < self . caches . length - 1 ) { return { status : 'continue' } ; } } //THIS ALLOWS false AS A VALID CACHE VALUE, BUT DO I WANT null TO BE VALID AS WELL? if ( result !== null && typeof result !== 'undefined' ) { log ( false , 'Key found:' , { key : key , value : result } ) ; return { status : 'break' , result : result } ; } var curCache = self . caches [ cacheIndex ] ; for ( var i = cacheIndex + 1 ; i < self . cachesLength ; i ++ ) { var nextCache = self . caches [ i ] ; if ( nextCache . checkOnPreviousEmpty || nextCache . expiration > curCache . expiration ) { return { status : 'continue' , toIndex : i } ; } } return { status : 'else' } ; }
Decides what action cacheService should take given the response from a configured cache
@param {string} key
@param {null | object} err
@param {null | object | string} result
@param {string} type
@param {integer} cacheIndex
Decides what action cacheService should take given the response from a configured cache