GuidesTypeScript API ReferencePython v2 API Reference
Guides

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:

  1. Create the VolatileLayerClient object.
  2. Create the DataRequest object 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);
  1. Call the getData method with the DataRequest parameter.
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
);