gpt4 book ai didi

Cassandra 将 TTL 添加到现有条目

转载 作者:行者123 更新时间:2023-12-02 23:25:30 26 4
gpt4 key购买 nike

如何更新整个表并为每个条目设置 TTL?

当前场景(Cassandra 2.0.11):

表:

CREATE TABLE external_users (
external_id text,
type int,
user_id text,
PRIMARY KEY (external_id, type)
)

目前此表中有大约 40mio 条目,我想添加一个 TTL,假设为 86 400 秒(1 天)。对于使用 TTL(86400) 或更新当前条目的新条目来说没有问题,但如何为每个现有条目应用 ttl?

我的想法是选择所有数据并使用一个小脚本更新每一行。我只是想知道是否有更简单的方法来实现这一点(因为即使批量更新,这也需要一段时间并且需要付出很大的努力)

提前致谢

最佳答案

无法更改 C* 中现有数据的 TTL。 TTL 只是一个内部列属性,它与所有其他列数据一起写入不可变的 SSTable。引用自the docs :

If you want to change the TTL of expiring data, you have to re-insert the data with a new TTL. In Cassandra, the insertion of data is actually an insertion or update operation, depending on whether or not a previous version of the data exists.

关于Cassandra 将 TTL 添加到现有条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30591321/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com