Cached calculations

Investigate automatically caches the computedData object. It supplies the cached computedData when trying to render or enrich the same document in the same script.

To control the time and scope of the computed cache, use the parameters computedDataTTL and shareComputedDataAcrossPerspectives. The default length of time is 2 minutes.

To avoid recalculating the existing data in the cached information, use if …​ else statements.

async function enrichRecordData({
  source, record, dataModelEntity, cancelPromise, computedData
}) {
  ...

  // Skip complex calculations if their results have been cached by Investigate
  if (computedData.raisedAmount === loading) {
    // We can fetch linked records using the "getLinkedRecords()" method of
    // the "Record" instance. We should always supply the maximum number of
    // records to return, plus the sorting order for the returned records.
    const securedInvestmentsRelation =
      (await sirenapi.Relation.getRelationsByLabel('secured'))[0];

    ...
  }
}

Next steps

To support execution cancellation in your script, see add support for cancellation.