Topik ini menjelaskan cara memperbarui konfigurasi tabel menggunakan Tablestore SDK untuk .NET.
Prasyarat
Klien telah diinisialisasi. Untuk informasi lebih lanjut, lihat Inisialisasi Klien Tablestore.
Deskripsi metode
public UpdateTableResponse UpdateTable(UpdateTableRequest request)Metode asinkron:
public Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request)Contoh kode
try
{
UpdateTableRequest request = new UpdateTableRequest("test_table");
// Informasi konfigurasi tabel.
TableOptions tableOptions = new TableOptions();
// Tentukan TTL dalam detik.
tableOptions.TimeToLive = 86400;
// Tentukan jumlah maksimum versi.
tableOptions.MaxVersions = 3;
// Tentukan offset versi maksimum dalam detik.
tableOptions.DeviationCellVersionInSec = 86400;
// Tentukan apakah pembaruan diperbolehkan.
tableOptions.AllowUpdate = false;
request.TableOptions = tableOptions;
// Aktifkan Stream dan atur periode validitas Stream menjadi tujuh hari.
StreamSpecification streamSpecification = new StreamSpecification(true);
streamSpecification.ExpirationTime = 168;
request.StreamSpecification = streamSpecification;
// Atur throughput baca tercadang ke 0 CU dan throughput tulis tercadang ke 0 CU (Anda dapat mengatur parameter ini ke nilai bukan nol dan pengaturan ini hanya berlaku untuk tabel data dalam instans performa tinggi dalam mode CU).
CapacityUnit reservedThroughput = new CapacityUnit(0, 0);
request.ReservedThroughput = reservedThroughput;
// Panggil metode UpdateTable untuk memodifikasi konfigurasi tabel.
client.UpdateTable(request);
Console.WriteLine("Pembaruan tabel berhasil.");
}
catch (Exception ex)
{
Console.WriteLine($"Pembaruan tabel gagal, pengecualian:{ex.Message}");
}