src/plugins/mongoose-cache.js
function (collectionKey, queryKey) {
  return new Promise(function (ok) {
    redisClient.multi().get(collectionKey).get(queryKey).exec(function (err, results) {
      if (err) {
        err.message = util.format('mongoose cache error %s', queryKey);
        debug(err);
        ok([null, null]); // ignore error, instead reject
        //return error(err);
      }

      var collectionData = results[0] && JSON.parse(results[0]),
        queryData = results[1] && JSON.parse(results[1]);
      //debug('redis cache object size', queryKey, helpers.getObjectSize(queryData));

      // special cache miss where it is out of date
      if (queryData && collectionData && collectionData.lastWrite > queryData.metadata.lastWrite) {
        debug('mongoose cache out of date: ', queryKey);
        queryData = null;
      }
      ok([collectionData, queryData]);
    });
  });
}
function (collectionKey, queryKey) {
  return new Promise(function (ok) {
    redisClient.multi().get(collectionKey).get(queryKey).exec(function (err, results) {
      if (err) {
        err.message = util.format('mongoose cache error %s', queryKey);
        debug(err);
        ok([null, null]); // ignore error, instead reject
        //return error(err);
      }

      var collectionData = results[0] && JSON.parse(results[0]),
        queryData = results[1] && JSON.parse(results[1]);
      //debug('redis cache object size', queryKey, helpers.getObjectSize(queryData));

      // special cache miss where it is out of date
      if (queryData && collectionData && collectionData.lastWrite > queryData.metadata.lastWrite) {
        debug('mongoose cache out of date: ', queryKey);
        queryData = null;
      }
      ok([collectionData, queryData]);
    });
  });
}
function ( collectionKey , queryKey ) { return new Promise ( function ( ok ) { redisClient . multi ( ) . get ( collectionKey ) . get ( queryKey ) . exec ( function ( err , results ) { if ( err ) { err . message = util . format ( 'mongoose cache error %s' , queryKey ) ; debug ( err ) ; ok ( [ null , null ] ) ; // ignore error, instead reject //return error(err); } var collectionData = results [ 0 ] && JSON . parse ( results [ 0 ] ) , queryData = results [ 1 ] && JSON . parse ( results [ 1 ] ) ; //debug('redis cache object size', queryKey, helpers.getObjectSize(queryData)); // special cache miss where it is out of date if ( queryData && collectionData && collectionData . lastWrite > queryData . metadata . lastWrite ) { debug ( 'mongoose cache out of date: ' , queryKey ) ; queryData = null ; } ok ( [ collectionData , queryData ] ) ; } ) ; } ) ; }
get query result = require(redis cache and check lastWrite
get query result = require ( redis cache and check lastWrite