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 after min seconds, at the latest after max seconds. Calling this function again with the same command will reset the internal timer unless the max 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)

Last updated on Nov 05, 2019.
next: IFRAME API
previous: LC.sys.*