如何使用 Achilles 更新 cassandra 中的 TTL,如果不存在则抛出异常

Posted

技术标签:

【中文标题】如何使用 Achilles 更新 cassandra 中的 TTL,如果不存在则抛出异常【英文标题】:How update TTL in cassandra using Achilles and throw an exception if it does not exist 【发布时间】:2015-04-17 18:28:28 【问题描述】:

我想使用 Achilles 更新 Cassandra 中对象的 TTL;但如果对象不存在,则应抛出异常。我想通过 LWT 对 Cassandra 进行一次操作。

我尝试了以下

DO do = asyncManager.forUpdate(DO.class, "not found");
OptionsBuilder.BuiltOptions options = OptionsBuilder.withTtl(5);
options.ifEqualCondition(MappingDO.TYPE_FIELD, "0");

try 
    asyncManager.update(do, options).get(2, TimeUnit.SECONDS);

catch (InterruptedException | ExecutionException | TimeoutException e) 
    // An LWT exception should be caught here since the object does not exist

由于对象不存在;我希望有条件的更新会失败。但是操作并没有失败。

【问题讨论】:

【参考方案1】:

为了使条件更新起作用;必须更新列。

在对象“do”上,必须至少指定键旁边的一个其他属性。该值不必与已经存在的不同。

【讨论】:

以上是关于如何使用 Achilles 更新 cassandra 中的 TTL,如果不存在则抛出异常的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Windows 中使用 Scala 将 Cassandra 与 Spark 连接起来

Cassandra 边界框搜索

集成数据库

cassandra安装

200分!heeljob!

无法启动 Cassandra:端口已在使用中