Chapter 6 temporary Global Variables and IRISTEMP Databases

For some operations, the capability of global variables may be required without the need to hold data indefinitely. For example, you might want to globally sort some data that doesn’t need to be stored to disk. For these operations, InterSystems IRIS provides a temporary global mechanism. The mechanism works as follows:

  • For application namespaces, a global mapping can be defined to map global variables with specific naming conventions toIRISTEMPDatabase, which is a special database, described below.

For example, you can define a global mapping to map all global variables named ^AcmeTemp* to the IRISTEMP database.

  • When the code needs to temporarily store data and read it again, the code writes to and reads from the global variable using the naming convention.

For example, to save a value, the code might do the following:

 set ^AcmeTempOrderApp("sortedarray")=some value
Copy the code

Later, the code might do the following:

 set somevariable = ^AcmeTempOrderApp("sortedarray")
Copy the code

By using temporary global variables, you can take advantage of the fact that the IRISTEMP database is not logged. Because the database has no diary records, operations using the database do not produce diary files. Log files can become very large and can cause space problems. However, please note the following:

You cannot roll back any transactions that modify global variables in the IRISTEMP database; This behavior is specific to IRISTEMP. If you need to work temporarily through transaction management, do not use global variables in IRISTEMP to do so.

Note that IRISTEMP is only used for work that does not require saving.

Define a mapping of temporary global variables

To define a mapping of temporary global variables, do the following:

  1. Choose a naming convention and make sure that all developers are aware of it. Please note the following points:
  • Consider whether you want to have multiple temporary globals or fewer temporary globals with multiple nodes. Compared to reading or writing the same number of independent global variables,InterSystems IRISEasier to read or write to different nodes in the same global variable efficiently. This efficiency difference is negligible for a few global variables, but when there are hundreds of independent global variables, the efficiency difference is very significant.

  • If you plan to use the same global mapping across multiple namespaces, design a system so that work in one namespace does not interfere with work in the other. For example, you can use a namespace name as a subscript in a global variable.

  • Similarly, even within a namespace, design a system so that each part of your code uses a different global or a different subscript within the same global to avoid interference.

  • Do not use the global name reserved by the system.

  1. On the PORTAL, navigate to the namespace page (System Administration > Configuration > System Configuration > Namespaces).
  2. In the row where the application namespace resides, click Global Mappings.
  3. On the Global Mapping page, click Create global Mapping.
  4. For the global database location, selectIRISTEMP.
  5. For global names, enter an asterisk (*) ending name. Do not include the first caret of the name.

For example: AcmeTemp *

This mapping causes all global variables whose names start with AcmeTemp* to be mapped to the IRISTEMP database.

  1. Click OK.

Note: >> appears in the first column of the new mapping row, indicating that the mapping is open for editing.

  1. To save the mappings for use by InterSystems IRIS, click Save the changes.

IRISTEMP system used

Note that InterSystems uses temporary global variables as temporary Spaces, for example, as temporary indexes during the execution of certain queries (for sorting, grouping, calculating aggregation, and so on).

Some of the system global variables included in IRISTEMP include:

  • ^IRIS.Temp*
  • ^mtemp*

Never change any of these global variables.