Expiration daemon module for Tarantool
Clone or download
SudoBobo Merge pull request #31 from tarantool/deploy-new-versions
add deploy to 1_9, 1_10 and 2_0 repos
Latest commit 7da3b43 May 29, 2018


expirationd - data expiration with custom quirks.

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.


space = box.space.old
job_name = 'clean_all'
expirationd = require('expirationd')
function is_expired(args, tuple)
  return true
function delete_tuple(space_id, args, tuple)
expirationd.start(job_name, space.id, is_expired, {
    process_expired_tuple = delete_tuple, args = nil,
    tuples_per_iteration = 50, full_scan_time = 3600

Expirationd API

expirationd.start (name, space_id, is_tuple_expired, options)

Run a named task

  • name - task name
  • space_id - space to look in for expired tuples
  • is_tuple_expired - a function, must accept tuple and return true/false (is tuple expired or not), receives (args, tuple) as arguments opt
  • options -- (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 removed
    • args - passed to is_tuple_expired() and process_expired_tuple() as additional context
    • tuples_per_iteration - number of tuples will be checked by one iteration
    • full_scan_time - time required for full index scan (in seconds)
    • force - run, even on replica

expirationd.kill (name)

Kill an existing task with name 'name'

  • name - task's name

expirationd.stats ([name])

if name is nil, then return map of name:stats, else return map with stats.

  • name - task's name, may be nil

expirationd.task (name)

Get task with name name

expirationd.tasks ()

Get copy of task list

expirationd.update ()

Update expirationd version and restart all tasks

Task API


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