How to get data from a volatile layer
A volatile layer consists of key-value pairs. Each new value for a key overrides the old one. Therefore, you can only get the latest data from the volatile layer.
To get data from the volatile layer:
- Create the
VolatileLayerClientobject. - Create the
DataRequestobject with the partition ID and fetch option.
The default fetch option is OnlineIfNotFound. It queries the network if the requested resource is not found in the cache. If you want to skip cache lookups and query the network right away, set the withFetchOption method to OnlineOnly.
const dataRequest = new DataRequest()
.withPartitionId("PartitionId")
.withBillingTag("MyBillingTag")
.withFetchOption(FetchOptions.OnlineOnly);- Call the
getDatamethod with theDataRequestparameter.
const partitions = await volatileLayerClient.getData(dataRequest);You receive data from the requested partition of the selected volatile layer.
In browser and Node.js, to abort requests before they have completed, you can create the AbortController object, and then add the AbortController.signal property to your requests. For more information, see the AbortController documentation.
Example:
const abortController = new AbortController();
const partitions = await volatileLayerClient.getData(
dataRequest,
abortController.signal
);Updated 9 days ago