更新 aerospike 中所有记录的 ttl
Update ttl for all records in aerospike
我被困在我已经初始化了一个命名空间的情况下
默认 ttl 为 30 天。大约有 500 万条数据具有该(30 天计算的)ttl 值。实际上,我的要求是ttl应该是零(0),但是它(ttl-30d)是在不知道或未识别的情况下保存的。
所以,现在我想用新的 ttl 值(零)更新 prev(旧)500 万数据。
我已经 checked/tried "set-disable-eviction true",但它不起作用,它正在根据(旧)ttl 值删除数据。
我该如何克服这个问题? (我想找回被删除的数据,我该怎么做?)
有人帮帮我。
首先,eviction and expiration are two different mechanisms. You can disable evictions in various ways, such as the set-disable-eviction
config parameter you've used. You cannot disable the cleanup of expired records. There's a good knowledge base FAQ What are Expiration, Eviction and Stop-Writes?. Unfortunately, the expired records that have been cleaned up are gone if their void time is in the past. If those records were merely evicted (i.e. removed before their void time due to crossing the namespace high-water mark for memory or disk) you can cold restart your node, and those records with a future TTL will come back. They won't return if either they were durably deleted 或者如果他们的 TTL 是过去的(跳过此类记录)。
至于重置 TTL,最简单的方法是通过 record UDF 执行此操作,该 record UDF 使用扫描应用于命名空间中的所有记录。
适合您情况的 UDF 非常简单:
ttl.lua
function to_zero_ttl(rec)
local rec_ttl = record.ttl(rec)
if rec_ttl > 0 then
record.set_ttl(rec, -1)
aerospike:update(rec)
end
end
在AQL中:
$ aql
Aerospike Query Client
Version 3.12.0
C Client Version 4.1.4
Copyright 2012-2017 Aerospike. All rights reserved.
aql> register module './ttl.lua'
OK, 1 module added.
aql> execute ttl.to_zero_ttl() on test.foo
我被困在我已经初始化了一个命名空间的情况下 默认 ttl 为 30 天。大约有 500 万条数据具有该(30 天计算的)ttl 值。实际上,我的要求是ttl应该是零(0),但是它(ttl-30d)是在不知道或未识别的情况下保存的。
所以,现在我想用新的 ttl 值(零)更新 prev(旧)500 万数据。
我已经 checked/tried "set-disable-eviction true",但它不起作用,它正在根据(旧)ttl 值删除数据。
我该如何克服这个问题? (我想找回被删除的数据,我该怎么做?)
有人帮帮我。
首先,eviction and expiration are two different mechanisms. You can disable evictions in various ways, such as the set-disable-eviction
config parameter you've used. You cannot disable the cleanup of expired records. There's a good knowledge base FAQ What are Expiration, Eviction and Stop-Writes?. Unfortunately, the expired records that have been cleaned up are gone if their void time is in the past. If those records were merely evicted (i.e. removed before their void time due to crossing the namespace high-water mark for memory or disk) you can cold restart your node, and those records with a future TTL will come back. They won't return if either they were durably deleted 或者如果他们的 TTL 是过去的(跳过此类记录)。
至于重置 TTL,最简单的方法是通过 record UDF 执行此操作,该 record UDF 使用扫描应用于命名空间中的所有记录。
适合您情况的 UDF 非常简单:
ttl.lua
function to_zero_ttl(rec)
local rec_ttl = record.ttl(rec)
if rec_ttl > 0 then
record.set_ttl(rec, -1)
aerospike:update(rec)
end
end
在AQL中:
$ aql
Aerospike Query Client
Version 3.12.0
C Client Version 4.1.4
Copyright 2012-2017 Aerospike. All rights reserved.
aql> register module './ttl.lua'
OK, 1 module added.
aql> execute ttl.to_zero_ttl() on test.foo