Skip to content

Commit

Permalink
add-scope-in-TTL (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amber1990Zhang committed Mar 31, 2020
1 parent 2ae6143 commit 1d81ad7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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"
请注意 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

0 comments on commit 1d81ad7

Please sign in to comment.