Calling udf at Aeropsike Record Expiration

Is there any way to call a user defined function immediately after record is going to expire, in order to perform some last minute functionality.

nope. want to elaborate on your use case? maybe we can come up with an alternative. alternatively it is open source so you could always code it in yourself… if you’re very brave.

So using UDF , I want to send an event/ alarm stating that certain record is deleted.

“Record Expiration” on a read operation looks at the server clock vs Time-to-live bytes (which is a future timestamp in the Primary Index). If server clock is ahead of the TTL timestamp, an incoming read operation will fail. (Record has expired). The underlying record storage is recovered at a later time by various maintenance threads, its just not accessible once the server clock is ahead of the TTL timestamp. Your best option is to launch a scan UDF that looks for records whose TTL is close to expiring (TTL - ServerClock < your_criterion) and do whatever you want to do to that record. You can use TTL=-2 so that you don’t alter its TTL in case you want to make some change to the record. If you just want to read the record, I haven’t tried it, but I think you could return back the record’s digest or data in some bin back to the client.

1 Like

You could also write in your desired expiration as a new bin and query it using a secondary index… @pgupta has a good suggestion too but I think it might be good to add an overhead when your set your ttl’s so that you can ensure you’re getting a scan of all of them before they disappear… @pgupta would a scan UDF be lighter than applying a UDF on predicate, or is that not possible (always get confused here)?

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.