LC.timeout.*¶
The module LC.timeout
allows calling Lua functions with a delay.
-
LC.timeout.
set
(command, min, max)¶ -
- Arguments
-
-
command (String) – Lua command to call
-
min (Number) – minimum time to wait
-
max (Number) – maximum time to wait
-
A timer is set to call
command
with a delay. The call is made at the earliest aftermin
seconds, at the latest aftermax
seconds. Calling this function again with the samecommand
will reset the internal timer unless themax
value has been reached.This function is used for example when an idempotent program is to be executed, but several successive calls within a short timeframe should be avoided.
The function name passed in
command
must be available in all Lua instances in the global namespace and can not accept any parameters.
Example
In this example, the function apache.reload
is executed at least 10 seconds after the last call to LC.timeout.set()
, but no later than 60 seconds after the first call:
LC.timeout.set('apache.reload', 10, 60)