Use Tablestore SDK for Go to update the TTL of an analytical store to extend data retention or delete historical data.
Prerequisites
An analytical store is created. For more information, see Create an analytical store.
A client is initialized. For more information, see Initialize a Tablestore client.
Usage notes
The synchronization option of an analytical store cannot be updated.
The minimum TTL of an analytical store is 30 days (2,592,000 seconds).
When you create an analytical store, if the TTL is not set to -1, Tablestore automatically deletes data whose retention period exceeds the TTL value from the analytical store in an asynchronous manner. You can also modify the TTL of the analytical store by calling the UpdateTimeseriesAnalyticalStore operation.
Data whose retention period exceeds the TTL value is invalid data. Even if the system has not deleted the invalid data, users can no longer read the data.
When you decrease the TTL value, data in the analytical store may expire, and the system will delete the corresponding expired data in an asynchronous manner.
When you increase the TTL value, if the system has not deleted the data whose retention period exceeds the old TTL value and the retention period of the data is less than or equal to the new TTL value, the data can still be read.
Parameters
UpdateTimeseriesAnalyticalStoreRequest contains the following parameters.
Name | Type | Description |
timeseriesTableName (required) |
| The name of the time series table. |
analyticStore (required) |
| The analytical store configuration to update. |
Analytical store configuration
analyticStore is of the TimeseriesAnalyticalStore type and contains the following parameters.
Name | Type | Description |
analyticalStoreName (required) |
| The name of the analytical store. |
timeToLive (required) |
| The analytical store TTL in seconds. Set the value to |
Example
The following sample code provides an example on how to update the configuration information and the TTL of data in an analytical store named test_analytical_store created for the test_timeseries_table time series table to 30 days (2,592,000 seconds):
func UpdateTimeseriesAnalyticalStore(client *tablestore.TimeseriesClient) {
analyticalStore := tablestore.NewTimeseriesAnalyticalStore("test_analytical_store")
analyticalStore.SetTimeToLive(2592000)
req := tablestore.NewUpdateTimeseriesAnalyticalStoreRequest("test_timeseries_table", analyticalStore)
_, err := client.UpdateTimeseriesAnalyticalStore(req)
if err != nil {
log.Fatal(err)
}
}