如何使用 ServiceStack.Aws 在 dynamodb 中设置 read/write 容量

How set up read/write capacity in dynamodb with ServiceStack.Aws

我想在 SeriviceStack.Aws 同步我的模型时设置自定义 read/write 容量。

我有这个型号

[Alias("TABLE-NAME")]
public class Company
{
    [AutoIncrement]
    public int CompanyId { get; set; }

    public int CountryId { get; set; }
    public string ShortName { get; set; }
    public string DocumentNumber { get; set; }
    public string FullName { get; set; }
    public string Address { get; set; }
    public DateTime CreatedAt { get; set; }
}

并使用此代码创建

var awsDb = new AmazonDynamoDBClient();
            var db = new PocoDynamo(awsDb)
                .RegisterTable<Company>();

            db.InitSchema();

如何设置自定义 read/write 容量?

table POCO 上的 ProvisionedThroughput capacities can be set through a ProvisionedThroughputAttribute 或默认值可以在 PocoDynamo 客户端上通过 ReadCapacityUnitsWriteCapacityUnits 属性进行控制。

表由 InitSchema 调用创建,该调用检查注册的 table 类型是否具有 ProvisionedThroughputAttribute first and falling back to the client specified capacities,默认设置为 10 读,5 写。