您好,我需要通过 AWS Java SDK 以编程方式为 DynamoDB 中的表设置时间.是否可以?我知道最近引入了 TTL 功能 - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html
Hi I need to set time to live programmatically for a table in DynamoDB via AWS Java SDK. Is it possible? I know that TTL feature is introduced recently - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html
更新:没有特别的注释,但我们可以手动做:
UPDATE: There is no special annotaion, but we can do it manually:
@DynamoDBAttribute
private long ttl;
并在 AWS 中将其配置为 ttl - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html
and configure it as ttl in AWS - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html
long now = Instant.now().getEpochSecond(); // unix time
long ttl = 60 * 60 * 24; // 24 hours in sec
setTtl(ttl + now); // when object will be expired
AmazonDynamoDBClient.updateTimeToLive 记录在 这里 或直接链接 这里
AmazonDynamoDBClient.updateTimeToLive documented here or direct link here
这篇关于如何在基于 Java 的应用程序中为 DynamoDB 设置 TTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)