Search code examples
c#servicestackamazon-dynamodbpocodynamo

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


I want to set up a custom read/write capacity when SeriviceStack.Aws synchronizes my model.

I have this model

[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; }
}

And is created with this code

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

            db.InitSchema();

How can set up a custom read/write capacity?


Solution

  • The ProvisionedThroughput capacities can be set through a ProvisionedThroughputAttribute on a table POCO or defaults can be controlled on the PocoDynamo client by the ReadCapacityUnits and WriteCapacityUnits properties.

    Tables are created by the InitSchema call which check if the registered table type has the ProvisionedThroughputAttribute first and falling back to the client specified capacities which by default are set to 10 Read, 5 Write.