To automatically delete historical data from an analytical store or extend its data retention period, you can use the UpdateTimeseriesAnalyticalStore operation to update the time to live (TTL) of the analytical store. After you update the TTL, Tablestore automatically and asynchronously deletes data that exceeds the new TTL.
Prerequisites
Notes
The synchronization options of an analytical store cannot be updated.
The minimum data lifecycle of an analytical store is 30 days (2,592,000 seconds).
If you do not set the TTL to -1 when you create an analytical store, Tablestore automatically and asynchronously deletes data that exceeds the specified TTL. You can also use the UpdateTimeseriesAnalyticalStore operation to modify the TTL of the analytical store.
Data that exceeds the TTL is considered expired. You can no longer read this data, even if the system has not yet deleted it.
If you decrease the TTL, some data in the analytical store may expire immediately. The system then asynchronously deletes the expired data.
If you increase the TTL, data that was expired under the old TTL but is now valid under the new TTL becomes readable again, provided that the system has not yet deleted the data.
Parameters
Parameter | Description | |
timeseriesTableName | The name of the time series table. | |
analyticalStore | analyticalStoreName | The name of the analytical store. |
timeToLive | The time to live for data in the analytical store, in seconds. Valid values: -1 (data never expires) or an integer greater than or equal to 2,592,000 (30 days). To prevent data in the analytical store from ever expiring, set this parameter to -1. | |
Example
The following example shows how to update the data lifecycle for an analytical store named test_analytical_store in the time series table test_timeseries_table to 30 days (2,592,000 seconds).
public void updateAnalyticalStore(TimeseriesClient client) {
// Set the name of the analytical store.
TimeseriesAnalyticalStore store = new TimeseriesAnalyticalStore("test_analytical_store");
// Update the data lifecycle of the analytical store to 2,592,000 seconds.
store.setTimeToLive(2592000);
// Set the name of the time series table.
UpdateTimeseriesAnalyticalStoreRequest request = new UpdateTimeseriesAnalyticalStoreRequest("test_timeseries_table");
request.setAnalyticStore(store);
client.updateTimeseriesAnalyticalStore(request);
}