Need help with ttl of keys in aerospike


#1

Hi Team,

I have set keys with particular ttl. How do I query how much time is remaining for the key to expire? I am using the Go client.


#2

It should be on any record you’ve pulled already, you just need to access it (either the entire record or just the header). I’m not familiar with the GO API but here are some references

func (*Client) Get func (clnt *Client) Get(policy *BasePolicy, key *Key, binNames …string) (*Record, error) Get reads a record header and bins for specified key. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) GetHeader func (clnt *Client) GetHeader(policy *BasePolicy, key *Key) (*Record, error) GetHeader reads a record generation and expiration only for specified key. Bins are not read. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

type Record struct { // Key is the record’s key. // Might be empty, or may only consist of digest value. Key *Key

// Node from which the Record is originating from.
Node *Node

// Bins is the map of requested name/value bins.
Bins BinMap

// Generation shows record modification count.
Generation uint32

// Expiration is TTL (Time-To-Live).
// Number of seconds until record expires.
Expiration uint32

}

So the expiration will be in the record…


#3

Since release 3.12 a predicate filter can be used in conjunction with a scan or query to find what you’re looking for.

Take a look at the PredExp class of the Java client and its examples. Predicate filtering also exists for the C, C# and Go clients.


#4

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.