localindexpiration=require'indexpiration'indexpiration.upgrade(box.space.myspace, {
field=number | 'name',
kind='time' | 'time64',
-- optional parameterstxn=false, -- disable transaction on batch deletionbatch_size=1000, -- change batch size (default 300)on_delete=function(tuple)
-- handler called on tuple just before delete-- must not yield if txn is usedend,
precise=true,
})
box.space.myspace.expiration:stop() -- stop expiration fiber-- ## Alternative check functionindexpiration.upgrade(box.space.myspace, {
field=number | 'name',
kind=function(t)
-- calculate time, left for tuple to live and return it.-- time MUST correlate with order in index for `field`-- this is sample of 'time64' kind (beware of unsigneds):returntonumber(
ffi.cast('int64_t',t[ expire_field_no ])
-ffi.cast('int64_t',clock.realtime64())
)/1e9end,
})
-- Not implemented yet:-- box.space.myspace.expiration:stat()-- box.space.myspace.expiration:pause()-- box.space.myspace.expiration:resume()