问题描述
您好,我需要通过 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设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)