从项目摘要而不是扫描中获取DynamoDB项目数量的方法是什么?

huangapple go评论79阅读模式
英文:

How do I get Dynamodb Item count from item summary NOT scan

问题

我正在尝试从我的DynamoDB表中返回项目计数。我已经有一个名为getLiveItemCount()的函数,大致如下:

func GetLiveItemCount(tableName string) *int64 {
	dynamodbClient := createDynamoDBClient()

	items, _ := dynamodbClient.Scan(&dynamodb.ScanInput{
		TableName: aws.String(tableName),
	})

	return items.Count
}

然而,我希望有另一个函数,可以从最近更新的项目指标中返回项目计数,就像item summary使用的那样(项目摘要包括项目计数表大小平均项目大小,每6小时更新一次)。有没有办法在Golang中获取这个值?

英文:

I'm trying to return the item count from my dynamodb table. I already have a getLiveItemCount() function which looks something like this:

func GetLiveItemCount(tableName string) *int64 {
	dynamodbClient := createDynamoDBClient()

	items, _ := dynamodbClient.Scan(&dynamodb.ScanInput{
		TableName: aws.String(tableName),
	})

	return items.Count
}

However, I'm looking to have another function that returns the item count from the most recently updated item metrics that item summary uses (items summary includes item count, table size, and Average item size which are updated every 6 hours). Is there any way to get this value in Golang?

答案1

得分: 1

要获取这些值,您可以调用DescribeTable函数:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html

英文:

To get those values you call DescribeTable:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html

huangapple
  • 本文由 发表于 2022年10月30日 10:57:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/74250230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定