How to set expiration at the bin level

Hi All,

I know that we can set Expiration in aerospike at record level. The whole record is going to expire with the expiration set in the policy.

but i want to set expiration at bin level. some where i read we can’t set expiration at bin level. so i’m trying to store all data for particular userid in one bin with different segment_id (6,8,15). and each segment has Expiration time(ExpTime). {“6”:{“from”:“Delhi”, “to”:“Mumbai”, “ExpTime”:“1434580456876”}, “8”:{“from”:“Delhi”, “to”:“Kolkata”, “ExpTime”:“1434580456876”},“15”:{“from”:“India”, “to”:“singapore”,ExpTime":“1434474636210”}}

if i’m going to write UDF to remove segment which has expired. then it will become very costly process. i’m storing json data format in bin.

please suggest other solution

You can still have a second bin to hold the expiration information, and do one of the following:

  1. Initiate a background scan to apply an expiration-check UDF to all the records with a low priority. See scan_apply, scan_info and scan options for setting priority.

  2. Passively check for expiration when you read the record. Do not actively scan the entire set to expire the bin; instead, only check when a record in that set is read. If the bin is expired, remove it before doing any further operations on it.

Thanks rbotzer,

currently i’m storing json in bin, can you suggest any other data object to store data in bin.

| {“6”:{“epoch”:“1434562694521”, “ExpTime”:“1434562694521”}, “8”:{“epoch”:“1433431212528”, “ExpTime”:“1433431212529”}} |

Hi Rahul,

You can ‘denormalize’ any of that data into separate bins where that data repeats. If that bin is called ‘data’ then add a bin ‘dataexp’ and copy the timestamp integer into it.

Does that make sense?

Hi rbotzer,

denormalize makes sense. but the main concern is that deletion of data. suppose i run a background process to check exptime and delete bin. at during that time my db become slow, that will effect my serving. 

i want to normalised all my process by using aerospike monitoring process. i don’t know aerospike have these feature or not.

Please suggest if you have any idea…

It would be your choice, but be aware that a background scan can include a policy which sets its priority, and either way scans are lower priority to the key-value operations. See Managing Scans.

This has already been done for you. Please see the following Aerospike github repository: