JBStrap InMemory DataDescriptor
Use the InMemory data descriptor to create a data source that stores data in the server memory. In this case, data values are not persisted. All data in the data descriptor is lost at server restart or application shutdown. Use these data descriptors to temporarily store or cache frequently queried data.
The InMemory data source stores data within the data source in the server memory. By default, stored data can be written and read by every part of the code in the client. This solution is optimal for temporary data storage.
Creating a simple InMemory DataDescriptor with an XML structure:
Programmatically creating an InMemory DataDescriptor that corresponds to the above XML:
In the above example we created a DataDescriptor, with three different column types. At this point the data source does not contain any data, resulting in an empty table.
Adding a few data rows (records) to the recently created DataDescriptor:
Consequently, we have 5 data rows in the DataDescriptor. We then use these data values to perform the usual operations through the data descriptor.
Getting all data from the DataDescriptor:
Getting data records that correspond to a give criterion:
Modifying a row in the data source (modifying the text value in the data record with the ID number: 3):
Removes a row from the DataDescriptor (deletes the data record with the ID number: 4):
In the above example a local InMemory DataDescriptor is used. This DataDescriptor provides data only for a specific program thread. Data operations by this DataDescriptor are invisible to other threads.
Other than local InMemory DataDescriptors, there are also global ones. Data operations by global InMemory DataDescriptors are visible to other program threads.
The following example demonstrates how to create a global InMemory DataDescriptor: