首页 文章

更新航空飞行中所有记录的ttl

提问于
浏览
5

我陷入了一种情况,我已经将default-ttl的一个名字初始化为30天 . 有大约500万个数据(30天计算)的ttl值 . 实际上,我的要求是ttl应为零(0),但It(ttl-30d)保持不知情或无法识别 .

所以,现在我想用新的ttl值(零)更新prev(旧)500万数据 .

我已经检查/尝试了“set-disable-eviction true”,但它无法正常工作,它正在根据(旧)ttl-value删除数据 .

我怎么克服这个? (我想检索删除的数据,我该怎么办?) .

谁来帮帮我 .

1 回答

  • 3

    首先,eviction和到期是两种不同的机制 . 您可以通过各种方式禁用驱逐,例如set-disable-eviction config参数,您是一个很好的知识库FAQ What are Expiration, Eviction and Stop-Writes? . 不幸的是,如果他们的空闲时间是过去的话,已经清理的过期记录就会消失 . 如果这些记录仅被驱逐(即由于跨越命名空间high-water mark的内存或磁盘而在其无效时间之前被删除),您可以冷重启节点,那些带有未来TTL的记录将返回 . 如果他们是durably deleted或他们的TTL过去(这些记录被跳过),他们将不会返回 .

    至于重置TTL,最简单的方法是通过使用扫描应用于命名空间中所有记录的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)
        -- for the TTL update to happen a bin must be 'dirty'
        -- set the first bin back with the value of the first bin
        -- no changes will occur other than the TTL change, but the
        -- aerospike:update(rec) will actually execute
        local bin_names = record.bin_names(rec)
        local do_nothing = rec[bin_names[1]]
        rec[bin_names[1]] = do_nothing
        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
    

相关问题