3

I want to store a Mapping of user's session ids in aerospike, it would be of the type:id->[session1, session2]. I want each session ID to have a specific TTL.

How can I get this done? Can I make a Map and put a TTL on each element?

1 Answer 1

4

In aerospike, ttl is a record level property. So, you cannot set it to an element in the list/map. For that matter, it cannot be set at bin level too.

So, you can store two sessions as two different records (by generating a composite key using userid and session id) with their respective ttls so that aerospike will automatically expire the records.

An alternative is to store the session ttl along with session id as a pair and handle session expiry from the application. You can set the max of all sessions as the ttl of the record. When all sessions expire, aerospike will expire the record from the system thereby freeing up space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.