...
Argument | Type | Description |
---|---|---|
cache key | Expression | Any valid Expression |
expressionN | Expression | Any valid Expression |
Examples
Example Setup
Code Block |
---|
$result = cache("accountRef", _cacheValue + 1) |
...
Code Block |
---|
$result = cache("accountRef", _cacheValue + 1) |
Example - generating Generating UIDs
This example is for the case where a user wants to generate UIDs in a specific way.
In this example, the stream table receives both updates for records in the system. So it can receive both records that exist in the system already, and those that are new. This stream existing records and new records. This table is used to correctly set/lookup the various ID fields.
Now if If 3 records came into this stream table that had the same value for a specific attribute (e.g. another ID field such as "BarcodeNumber"), then we do not want to generate a new ID for each record... , instead, we want to generate it once a single ID and then use that this value for the other all three records. The configuration is as follows:
Code Block |
---|
do( if($newRecord, // then do( $recordID = cache(_out.BarcodeNumber, if( _cacheValue == _NULL, // then $recordID = nextValue('RecordID'), // else _cacheValue ) ) ), // else $recordID = in.RecordID ), $recordID ) |
...
This expression above uses the cache function to hold a newly generated ID (nextValue('RecordID') in memory for each unique _out.BarcodeNumber field. So the 1st record that is processed gets the new ID generated by the sequence, and then any subsequent records that are processed will find a match for their BarcodeNumber in the cache, and take that ID that was generated for the 1st BarcodeNumber.
...