Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add-scope-in-TTL #7

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

ttl 功能需要 `ttl_col` 和 `ttl_duration` 一起使用。自从 `ttl_col` 指定的字段的值起,经过 `ttl_duration` 指定的秒数后,该条数据过期。即,到期阈值是 `ttl_col` 指定的 property 的值加上 `ttl_duration` 设置的秒数。其中 `ttl_col` 指定的字段的类型需为 integer 或者 timestamp。

!!! note "NOTE"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实没看懂。。。听上去就是个bug。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug, it's an issue, do it when need it

请注意 TTL 目前仅适用于 [FETCH](../2.data-query-and-manipulation-statements/fetch-syntax.md)、[GO](../2.data-query-and-manipulation-statements/go-syntax.md) 和 compaction。

## TTL 配置

- `ttl_duration` 单位为秒,当 `ttl_duration` 被设置为 -1 或者 0,则点的此 tag 属性不会过期。
- `ttl_duration` 单位为秒,范围为 0 ~ max(int64),当 `ttl_duration` 被设置为 0,则点的此 tag 属性不会过期。

- 当 `ttl_col` 指定的字段的值 + `ttl_duration` 值 < 当前时间时,该条数据此 tag 属性值过期。

Expand Down Expand Up @@ -63,7 +66,7 @@ nebula> FETCH PROP ON * 200;

## 删除 TTL

如果想要删除 TTL,可以设置 `ttl_col` 字段为空,或删除配置的 `ttl_col` 字段,或者设置 `ttl_duration` 为 0 或者 -1
如果想要删除 TTL,可以设置 `ttl_col` 字段为空,或删除配置的 `ttl_col` 字段,或者设置 `ttl_duration` 为 0。

```ngql
nebula> ALTER TAG t1 ttl_col = ""; -- drop ttl attribute;
Expand All @@ -75,7 +78,7 @@ nebula> ALTER TAG t1 ttl_col = ""; -- drop ttl attribute;
nebula> ALTER TAG t1 DROP (a); -- drop ttl_col
```

设置 ttl_duration 为 0 或者 -1
设置 ttl_duration 为 0:

```ngql
nebula> ALTER TAG t1 ttl_duration = 0; -- keep the ttl but the data never expires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ With **TTL**, **Nebula Graph** provides the ability to delete the expired vertic

TTl requires `ttl_col` and `ttl_duration` together. `ttl_col` indicates the TTL column, while `ttl_duration` indicates the duration of the TTL. When the sum of the TTL column and the ttl_duration is less than the current time, we consider the data as expired. The `ttl_col` type is integer or timestamp, and is set in seconds. `ttl_duration` is also set in seconds.

!!! note "Note"
Please be noted that TTL currently available fot [FETCH](../2.data-query-and-manipulation-statements/fetch-syntax.md), [GO](../2.data-query-and-manipulation-statements/go-syntax.md) and compaction.

## TTL configuration

- The `ttl_duration` is set in seconds. If it is set to -1 or 0, the vertex properties of this tag does not expire.
- The `ttl_duration` is set in seconds and ranges from 0 to max(int64). If it is set to 0, the vertex properties of this tag does not expire.

- If TTL is set, when the sum of the `ttl_col` and the `ttl_duration` is less than the current time, we consider the vertex properties of this tag as expired after the specified seconds configured by `ttl_duration` has passed since the `ttl_col` field value.

Expand Down Expand Up @@ -63,7 +66,7 @@ nebula> FETCH PROP ON * 200;

## Dropping TTL

If you have set a TTL value for a field and later decide do not want it to ever automatically expire, you can drop the TTL value, set it to an empty string or invalidate it by setting it to 0 or -1.
If you have set a TTL value for a field and later decide do not want it to ever automatically expire, you can drop the TTL value, set it to an empty string or invalidate it by setting it to 0.

```ngql
nebula> ALTER TAG t1 ttl_col = ""; -- drop ttl attribute;
Expand Down