src/record/record-request.js
function onCacheResponse (
  error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
  if (error) {
    sendError(
      C.EVENT.RECORD_LOAD_ERROR,
      `error while loading ${recordName} from cache:${error.toString()}`,
      recordName,
      socketWrapper,
      onError,
      options,
      context,
      metaData
    )
  } else if (record) {
    onComplete.call(context, record, recordName, socketWrapper)
  } else if (
      !options.storageExclusion ||
      !options.storageExclusion.test(recordName)
    ) {

    let storageTimedOut = false
    const storageTimeout = setTimeout(() => {
      storageTimedOut = true
      sendError(
        C.EVENT.STORAGE_RETRIEVAL_TIMEOUT,
        recordName, recordName, socketWrapper,
        onError, options, context, metaData
      )
    }, options.storageRetrievalTimeout)

    options.storage.get(recordName, (storageError, recordData) => {
      if (!storageTimedOut) {
        clearTimeout(storageTimeout)
        onStorageResponse(
          storageError,
          recordData,
          recordName,
          socketWrapper,
          onComplete,
          onError,
          options,
          context,
          metaData
        )
      }
    }, metaData)
  } else {
    onComplete.call(context, null, recordName, socketWrapper)
  }
}
function onCacheResponse (
  error, record, recordName, socketWrapper, onComplete, onError, options, context, metaData
) {
  if (error) {
    sendError(
      C.EVENT.RECORD_LOAD_ERROR,
      `error while loading ${recordName} from cache:${error.toString()}`,
      recordName,
      socketWrapper,
      onError,
      options,
      context,
      metaData
    )
  } else if (record) {
    onComplete.call(context, record, recordName, socketWrapper)
  } else if (
      !options.storageExclusion ||
      !options.storageExclusion.test(recordName)
    ) {

    let storageTimedOut = false
    const storageTimeout = setTimeout(() => {
      storageTimedOut = true
      sendError(
        C.EVENT.STORAGE_RETRIEVAL_TIMEOUT,
        recordName, recordName, socketWrapper,
        onError, options, context, metaData
      )
    }, options.storageRetrievalTimeout)

    options.storage.get(recordName, (storageError, recordData) => {
      if (!storageTimedOut) {
        clearTimeout(storageTimeout)
        onStorageResponse(
          storageError,
          recordData,
          recordName,
          socketWrapper,
          onComplete,
          onError,
          options,
          context,
          metaData
        )
      }
    }, metaData)
  } else {
    onComplete.call(context, null, recordName, socketWrapper)
  }
}
function onCacheResponse ( error , record , recordName , socketWrapper , onComplete , onError , options , context , metaData ) { if ( error ) { sendError ( C . EVENT . RECORD_LOAD_ERROR , ` ${ recordName } ${ error . toString ( ) } ` , recordName , socketWrapper , onError , options , context , metaData ) } else if ( record ) { onComplete . call ( context , record , recordName , socketWrapper ) } else if ( ! options . storageExclusion || ! options . storageExclusion . test ( recordName ) ) { let storageTimedOut = false const storageTimeout = setTimeout ( ( ) => { storageTimedOut = true sendError ( C . EVENT . STORAGE_RETRIEVAL_TIMEOUT , recordName , recordName , socketWrapper , onError , options , context , metaData ) } , options . storageRetrievalTimeout ) options . storage . get ( recordName , ( storageError , recordData ) => { if ( ! storageTimedOut ) { clearTimeout ( storageTimeout ) onStorageResponse ( storageError , recordData , recordName , socketWrapper , onComplete , onError , options , context , metaData ) } } , metaData ) } else { onComplete . call ( context , null , recordName , socketWrapper ) } }
Callback for responses returned by the cache connector

@private
@returns {void}
Callback for responses returned by the cache connector