You can use appropriate long-lived ESQL data types to cache data in memory.
Sometimes data has to be stored beyond the lifetime of a single message passing through a flow. One way to store this data is to store the data in a database. Using a database is good for long-term persistence and transactionality, but access (particularly write access) is slow.
Alternatively, you can use appropriate long-lived ESQL data types to provide an in-memory cache of the data for a certain period of time. Using long-lived ESQL data types makes access faster than from a database, although this speed is at the expense of shorter persistence and no transactionality.
You create long-lifetime variables by using the SHARED keyword on the DECLARE statement. For further information, see DECLARE statement.
You can view information about samples only when you use the product documentation that is integrated with the IBM® Integration Toolkit or the online product documentation. You can run samples only when you use the product documentation that is integrated with the IBM Integration Toolkit.
Long-lived data types have an extended lifetime beyond that of a single message passing through a node. Long-lived data types are shared between threads and exist for the life of a message flow (the time between configuration changes to a message flow), as described in the following tables.
Scope | Life | Shared | |
---|---|---|---|
Schema & Module | Node | Thread within node | Not at all |
Routine Local | Node | Thread within routine | Not at all |
Block Local | Node | Thread within block | Not at all |
Scope | Life | Shared | |
---|---|---|---|
Node Shared | Node | Life of node | All threads of flow |
Flow Shared | Flow | Life of flow | All threads of flow |
A typical use of these data types might be in a flow in which data tables are 'read-only' as far as the flow is concerned. Although the table data is not actually static, the flow does not change it, and thousands of messages pass through the flow before there is any change to the table data.