# openresty-lua-timer **Repository Path**: baiyangzhuhong/openresty-lua-timer ## Basic Information - **Project Name**: openresty-lua-timer - **Description**: 基于openresty ngx_lua开发的一款应用于定时作业的定时器框架,支持创建和取消定时器。 框架基础代码从开源项目lua-resty-timer(https://github.com/Kong/lua-resty-timer)而来,但对框架存在的内存泄漏问题进行了修复,并添加了一些方便管理的接口,及一些代码机制的调整。 - **Primary Language**: Lua - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2021-10-11 - **Last Updated**: 2022-11-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # openresty-lua-timer #### 介绍 基于openresty ngx_lua开发的一款应用于定时作业的定时器框架,支持创建和取消定时器。 框架基础代码从开源项目`lua-resty-timer(https://github.com/Kong/lua-resty-timer)`而来,但对框架存在的内存泄漏问题进行了修复,并添加了一些方便管理的接口,及一些代码机制的调整。 #### 安装教程 下载源码, 使用luarocks编译安装 #### 使用说明 ```lua -- create timer local resty_timer = require("resty.timer") local interval = 5 -- seconds local health_mode = "healthy" local CHECK_JITTER = 0.1 local function callback () end local timer_uuid, err = resty_timer({ interval = interval, recurring = true, immediate = true, detached = true, expire = callback, cancel = nil, shm_name = self.shm_name, key_name = self.PERIODIC_LOCK .. health_mode, sub_interval = math.min(interval, 0.5), jitter = CHECK_JITTER, }, self.name, health_mode) if not timer_uuid then -- log end ``` #### 参与贡献 1. Fork 本仓库 2. 提交代码 3. 新建 Pull Request