This module allows the delayed execution of LUA scripts, both periodic and one-time.
- Obtain a redis server version 4.0 or above (with module support)
- Download and compile redis-timer (
make
) - Start the redis server with the timer module:
- By adding this line to redis.conf:
loadmodule /path/to/timer.so
- By using a command-line argument:
redis-server --load-module /path/to/timer.so
- By running the command:
MODULE LOAD /path/to/timer.so
- By adding this line to redis.conf:
Create and activate a new timer.
The LUA script referenced by sha1
will be
executed after milliseconds
. If LOOP
is specified, after the execution a
new timer will be setup with the same time.
Notes:
- if the script is unloaded, the timer will be deleted
- no info is provided regarding the execution of the script
- for simplicity, in periodic timers the execution interval will start counting at the end of the previous execution, and not at the beginning. After some time, the exact time of the triggering may be difficult to deduce, particularly if the the script takes a long time to execute or if different executions require different ammounts of time.
Reply: the id of the timer.
Removes a timer.
Reply: OK if succesfull, error otherwise.
Provides info of a timer.
Reply: an array with the following items:
- the id of the timer
- the sha1 of the script
- the remaining time (milliseconds to the next execution)
- the time interval if it is a periodic timer, or 0 otherwise
Provides info for all the active timers.
Reply: an array with one subarray per timer, with the same format of the TIMER.INFO
command.
Issue reports, pull and feature requests are welcome.
MIT - see LICENSE