其他分享
首页 > 其他分享> > 如何使用ServiceStack.Aws在dynamodb中设置读取/写入容量

如何使用ServiceStack.Aws在dynamodb中设置读取/写入容量

作者:互联网

我想在SeriviceStack.Aws同步我的模型时设置自定义读/写功能.

我有这个模特

[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();

如何设置自定义读/写容量?

解决方法:

可以通过表POCO上的ProvisionedThroughputAttribute设置ProvisionedThroughput容量,或者可以通过ReadCapacityUnits和WriteCapacityUnits属性在PocoDynamo客户端上控制默认值.

通过InitSchema调用创建表,该表检查已注册的表类型是否首先具有ProvisionedThroughputAttributefalling back to the client specified capacities,默认情况下它们设置为10 Read,5 Write.

标签:amazon-dynamodb,servicestack,c,pocodynamo
来源: https://codeday.me/bug/20191026/1940335.html