This package can turn Tarantool into a persistent memcache replacement, but is powerful enough so that your own expiration strategy can be defined.
You define two functions: one takes a tuple as an input and returns true in case it's expirted and false otherwise. The other takes the tuple and performs the expiry itself: either deletes it (memcache), or does something smarter, like put a smaller representation of the data being deleted into some other space.
box.cfg{}
space = box.space.old
job_name = 'clean_all'
expirationd = require('expirationd')
function is_expired(args, tuple)
return true
end
function delete_tuple(space_id, args, tuple)
box.space[space_id]:delete{tuple[1]}
end
expirationd.start(job_name, space.id, is_expired, {
process_expired_tuple = delete_tuple, args = nil,
tuples_per_iteration = 50, full_scan_time = 3600
})
Run a named task
name
- task namespace_id
- space to look in for expired tuplesis_tuple_expired
- a function, must accept tuple and return true/false (is tuple expired or not), receives(args, tuple)
as arguments optoptions
-- (table with named options, may be nil)process_expired_tuple
- applied to expired tuples, receives(space_id, args, tuple)
as arguments. Can be nil: by default tuples are removedargs
- passed tois_tuple_expired()
andprocess_expired_tuple()
as additional contexttuples_per_iteration
- number of tuples will be checked by one iterationfull_scan_time
- time required for full index scan (in seconds)force
- run, even on replica
Kill an existing task with name 'name'
name
- task's name
if name
is nil, then return map of name
:stats
, else return map with stats.
name
- task's name, may be nil
Get task with name name
Get copy of task list
Update expirationd version and restart all tasks
Force start task
(old guardian_fiber will be garbage collected,
so do task:stop()
before or task:restart()
instead)
Stop task and delete it from list of tasks.
Get statistics of task
Simply start tarantool test.lua