本文介绍如何通过 .NET SDK 更新表的配置信息。
前提条件
方法说明
public UpdateTableResponse UpdateTable(UpdateTableRequest request)
异步方法:
public Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request)
示例代码
try
{
UpdateTableRequest request = new UpdateTableRequest("test_table");
// 表配置信息
TableOptions tableOptions = new TableOptions();
// 设置数据生命周期,单位为秒
tableOptions.TimeToLive = 86400;
// 设置最大版本数
tableOptions.MaxVersions = 3;
// 设置有效版本偏差,单位为秒
tableOptions.DeviationCellVersionInSec = 86400;
// 设置是否允许更新
tableOptions.AllowUpdate = false;
request.TableOptions = tableOptions;
// 开启Stream信息,并设置Stream过期时间为7天
StreamSpecification streamSpecification = new StreamSpecification(true);
streamSpecification.ExpirationTime = 168;
request.StreamSpecification = streamSpecification;
// 设置预留读为0CU,预留写为0CU(仅CU模式高性能实例支持设置数据表的预留读写吞吐量为非零值)
CapacityUnit reservedThroughput = new CapacityUnit(0, 0);
request.ReservedThroughput = reservedThroughput;
// 调用UpdateTable方法修改表配置
client.UpdateTable(request);
Console.WriteLine("Update table succeeded.");
}
catch (Exception ex)
{
Console.WriteLine($"Update table failed, exception:{ex.Message}");
}
该文章对您有帮助吗?