我很难理解AeroSpike文档中的以下内容:
http://www.aerospike.com/docs/client/python/usage/kvs/record-structure.html一条记录也有两个与它相关联的元数据值——记录的生成(它被修改的次数)和它的生存时间。ttl可以设置为剩余的秒数,直到它被认为过期,或者设置为0(用于"永不过期",默认值)。ttl过期的记录将由服务器进行垃圾回收。每次写入或触摸记录(使用touch())时,其ttl将重置。
我最初的想法是,如果命名空间策略默认ttl设置为0,那么记录将不会过期。
我的Aerospike命名空间配置如下:
namespace brand {
replication-factor 2
memory-size 4G
default-ttl 0 # 30 days, use 0 to never expire/evict.
storage-engine memory
# To use file storage backing, comment out the line above and use the
# following lines instead.
set twitter {
set-disable-eviction true
}
storage-engine device {
file /opt/aerospike/data/bar.dat
filesize 16G
data-in-memory true # Store data in memory in addition to file.
}
}
我对数据库进行了一些插入,然后当我检索数据时,我得到了以下内容:
{ name: 'test',
twitter: 'test',
domain: 'test.com',
description: 'Your First Round Fund' } { ttl: 4294967295, gen: 2 }
记录上出现了一个ttl,其他记录也有一个ttl。我不希望我的记录从数据库中被删除。如何从记录中删除ttl以及如何防止将来发生这种情况?
"asadm -e 'show stat like ttl'
显示如下:
~~~~brand Namespace Statistics~~~~
NODE : 1
cold-start-evict-ttl: 4294967295
default-ttl : 0
max-ttl : 0
~~~~test Namespace Statistics~~~~~
NODE : 1
cold-start-evict-ttl: 4294967295
default-ttl : 2592000
max-ttl : 0
asinfo -v 'hist-dump:ns=brand;hist=ttl'
显示以下
brand:ttl=100,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
node.js get操作元信息显示{ttl: 4294967295, gen: 2}.
好吧!所以TTL无符号32位整数,你看到的最大值是(2^32 -1)如果它是有符号的,它会是-1。最大值在Aerospike中具有特殊的意义,它意味着它的寿命是无限的。Aerospike已经接受了-1作为一年内的不确定值,而客户端的0表示使用服务器默认值。
node.js客户端基于我们的c客户端,该客户端被更改为将ttl 0值从服务器转换为0xFFFFffff或-1。这在c客户端的3.0.51发行说明中提到过。
感谢你强调这个问题,看起来这个领域有一些过时的文档