卡桑德拉 TTL 不工作
Cassandra TTL not working
我正在将 datastax 与 cassandra 一起使用。我希望一行在插入 15 分钟后自动删除。但争吵依然存在。
我的代码如下:
Insert insertStatement = QueryBuilder.insertInto(keySpace, "device_activity");
insertStatement.using(QueryBuilder.ttl(15* 60));
insertStatement.value("device", UUID.fromString(persistData.getSourceId()));
insertStatement.value("lastupdatedtime", persistData.getLastUpdatedTime());
insertStatement.value("devicename", persistData.getDeviceName());
insertStatement.value("datasourcename", persistData.getDatasourceName());
table 由 4 列组成:设备 (uuid)、数据源名称(文本)、设备名称(文本)、上次更新时间(时间戳)。
如果我查询某个字段的 TTL,它会显示 4126 秒,这是错误的。
//Select 来自 device_activity 的 TTL(设备名称); // 给我 4126 秒
下面link对TTL进行了说明
https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_expire_c.html
"TTL data has a precision of one second, as calculated on the server. Therefore, a very small TTL probably does not make much sense. Moreover, the clocks on the servers should be synchronized; otherwise reduced precision could be observed because the expiration time is computed on the primary host that receives the initial insertion but is then interpreted by other hosts on the cluster."
看完这篇我可以通过在相应的节点(机器)上设置适当的时间来解决
我正在将 datastax 与 cassandra 一起使用。我希望一行在插入 15 分钟后自动删除。但争吵依然存在。
我的代码如下:
Insert insertStatement = QueryBuilder.insertInto(keySpace, "device_activity");
insertStatement.using(QueryBuilder.ttl(15* 60));
insertStatement.value("device", UUID.fromString(persistData.getSourceId()));
insertStatement.value("lastupdatedtime", persistData.getLastUpdatedTime());
insertStatement.value("devicename", persistData.getDeviceName());
insertStatement.value("datasourcename", persistData.getDatasourceName());
table 由 4 列组成:设备 (uuid)、数据源名称(文本)、设备名称(文本)、上次更新时间(时间戳)。
如果我查询某个字段的 TTL,它会显示 4126 秒,这是错误的。 //Select 来自 device_activity 的 TTL(设备名称); // 给我 4126 秒
下面link对TTL进行了说明
https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_expire_c.html
"TTL data has a precision of one second, as calculated on the server. Therefore, a very small TTL probably does not make much sense. Moreover, the clocks on the servers should be synchronized; otherwise reduced precision could be observed because the expiration time is computed on the primary host that receives the initial insertion but is then interpreted by other hosts on the cluster."
看完这篇我可以通过在相应的节点(机器)上设置适当的时间来解决