/tarantool-capped-expirationd

non-lua expiration daemon module for tarantool

Primary LanguageC

HOWTO

How to build:

git clone https://github.com/sonntex/tarantool-capped-expirationd.git
cd tarantool-capped-expirationd
cmake .
make

How to grant permissions:

box.cfg{listen=3300}
box.schema.func.create('libcapped-expirationd.start', {language = 'C'})
box.schema.user.grant('guest', 'execute', 'function', 'libcapped-expirationd.start')
box.schema.func.create('libcapped-expirationd.kill', {language = 'C'})
box.schema.user.grant('guest', 'execute', 'function', 'libcapped-expirationd.kill')

How to create space:

box.cfg{listen=3300}
fiber = require('fiber')
box.schema.space.create('tester') 
box.space.tester:create_index('primary', {unique = true, parts = {1, 'unsigned'}})
box.space.tester:create_index('exp', {unique = false, parts = {3, 'unsigned'}})
box.space.tester:insert{0, '0@tarantool.io', math.floor(fiber.time()) + 60}
box.space.tester:insert{1, '1@tarantool.io', math.floor(fiber.time()) + 60}
box.space.tester:insert{2, '2@tarantool.io', math.floor(fiber.time()) + 60}

How to start task for non-indexed exp field:

box.cfg{listen=3300}
net_box = require('net.box')
connection = net_box:new(3300)
connection:call('libcapped-expirationd.start', {'tester', box.space.tester.id, box.space.tester.index.primary, box.space.tester.index.primary, 3, 1024, 3600})

How to start task for indexed exp field:

box.cfg{listen=3300}
net_box = require('net.box')
connection = net_box:new(3300)
connection:call('libcapped-expirationd.start', {'tester', box.space.tester.id, box.space.tester.index.primary, box.space.tester.index.exp, 3, 1024, 3600})