本文介绍了Cassandra TTL用于表行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在second-1插入一列,在second-2插入另一列。表的默认TTL设置为10秒,例如:

Suppose I inserted a column at second-1 and another column at second-2. Default TTL for table is set to 10 seconds for example:

问题1 :是要在10秒后删除data1和data2还是要删除data 1将在10秒后删除,data-2在11秒后删除(因为它是在second-2中插入的)?

Question 1: Is data1 and data2 going to be deleted after 10 seconds or data 1 will be deleted after 10 seconds and data-2 after 11 seconds ( as it was inserted in second-2)?

问题2 :是否可以在表级别设置TTL,使得表中的每个条目根据以FIFO方式设置TTL? (数据1在第二个10终止,数据2在第二个11终止),在为每个数据点插入时是否指定TTL? (应该能够在表级别指定?)

Question 2: Is it possible to set a TTL at a table level in such a way that each entry in the table will expire based on the TTL in a FIFO fashion ? (data-1 will expire at second-10 and data-2 at second-11), without specifying TTL while inserting for each data point? (Should be able to specify at a table level ?)

感谢帮助:)

编辑

位于说

CQL表定义支持default_time_to_live属性
,该属性应用特定的TTL表中的每一列。在超过
default_time_to_live TTL值之后,Cassandra墓碑将整个表中的
删除。使用
CREATE TABLE或ALTER TABLE

The CQL table definition supports the default_time_to_live property, which applies a specific TTL to each column in the table. After the default_time_to_live TTL value has been exceed, Cassandra tombstones the entire table. Apply this default TTL to a table in CQL using CREATE TABLE or ALTER TABLE

将此默认TTL应用于CQL中的表,他们说整个表我。

they say "entire table" which confused me.

推荐答案

表级别的TTL与级别的TTL丝毫没有不同:指定每行的默认 TTL时间。

TTL at table level is by no means different than TTL at values level: it specifies the default TTL time for each row.

TTL指定在几秒钟后必须将值视为过时并删除的值。参考点是INSERT / UPDATE时间戳记,因此,如果您在09:53:01插入/更新一行:

The TTL specifies after how many seconds the values must be considered outdated and thus deleted. The reference point is the INSERT/UPDATE timestamp, so if you insert/update a row at 09:53:01:


  • 具有TTL 10秒,它将终止于09:53:11

  • ,TTL为15秒,它将终止于09:53:16

  • TTL为0秒,它将永不过期

您可以通过以下方式覆盖默认 TTL时间:在查询中指定使用TTL X 子句,其中X是您的新TTl值。

You can override the default TTL time by specifying USING TTL X clause in your queries, where X is your new TTl value.

请注意,使用TTL 明智地会导致墓碑问题。还要注意,TTL用法有一些奇怪之处。请查看最新答案,以获取更多详细信息。

Please note that using TTL not wisely can cause tombstones problems. And note also that the TTL usage have some quirks. Have a look at this recent answer for further details.

这篇关于Cassandra TTL用于表行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 05:36