Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt
hiddentrue

cache(cache key, expression1, expression2,..., expressionN) Build and use a set of values across the records in a stream setrecordset.

Function: cache()

Build and use a set of values across the records in a stream setrecordset.

The first parameter is the cache key expression. This is evaluated and the result used as the key value for the cache. Before the subsequent expressions are evaluated the key value is used to retrieve the current value from the cache associated with that key. This retrieved value is then assigned to the internal variable _cacheValue. If there was no value in the cache for this key then _cacheValue is set to _NULL.

This cache key expression is followed by a number of additional expressions. These are evaluated in turn, and the value returned by the final expression is placed into the cache against the original key value.

The final cache value is returned by the expression.

Please note that the internal variable _cacheValue should not be used outside of the cache function.

...

It is only necessary to be concerned about synchronisation if the same key will be used across multiple parcels of work. However, this consideration can become complex, so as a general rule, try and use a single call to the cache function in the stream table configuration.

Example

You have a calculate stream table processing, say, 10,000 records - and you want to accumulate totals based on a key value, of which there are 100 across the data set. For each key value, many records will be added to the total. To do this, you should use a call to the cache function such as:

...