2015-10-23 28 views
2

我有很難理解從塞文檔如下:塞在我的記錄創建TTL

http://www.aerospike.com/docs/client/python/usage/kvs/record-structure.html

的記錄也有兩個與之相關的元數據值 - 記錄生成(數它被修改過的次數)和它的ttl。可以將ttl設置爲剩餘的秒數,直到它被認爲過期,或者設置爲0(對於'never expire'和默認值)。 ttl已過期的記錄將被服務器垃圾收集。每次寫入或觸摸記錄(使用touch())時,它的ttl都會重置。

我最初的想法是,如果名稱空間策略默認ttl設置爲0,則記錄不會過期。

我塞式命名空間的配置如下:

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; 
+0

(單獨的問題)定義了2個存儲引擎。 「存儲引擎內存」僅用於內存中的名稱空間。 – kporter

+0

你可以運行並提供「asadm -e」展示統計信息,例如ttl'「 – kporter

+1

用」asadm -e'顯示統計信息如ttl'更新了答案「 – rastacide

回答

4

Node.js的獲取操作的元信息顯示{TTL:4294967295,創:2}。

好吧!所以TTL無符號的32位整數,你看到的最大值(2^32 -1)如果它是一個簽名它將是-1。最大值在Aerospike中具有特殊含義,意味着它無限期地存在。 Aerospike已經接受-1作爲無限期約一年,而客戶端0表示使用服務器默認。

node.js客戶端基於我們的c客戶端,它已被更改爲將ttl 0值從服務器轉換爲0xFFFFffff或-1。這在c client's 3.0.51 release notes中被提及。

感謝您強調這個問題,看起來像這個地區有一些陳舊的文檔。

+1

非常感謝你澄清這一點:) – rastacide

相關問題