MoonScript版的Ngx.Timer

作者:糖果

实际如果是直接调用ngx.timer的API,moonscript和lua的ngx.timer的函数写法差别不是很大。

candylab.moon

handler = (fill, params)->
    ok, err = ngx.timer.at(1, handler, "params-data")
    ngx.log(ngx.DEBUG, "ok:", ok, " err:", err)
         
ok, err = ngx.timer.at(6, handler, "params-data")
   
            
if not ok then
    ngx.log(ngx.ERR, "err:", err)

candylab.lua

local http = require("lapis.nginx.http")

local handler
handler = function(fill, params)
  local ok, err = ngx.timer.at(1, handler, "params-data")
  return ngx.log(ngx.DEBUG, "ok:", ok, " err:", err)
end

local ok, err = ngx.timer.at(6, handler, "params-data")

if not ok then
  return ngx.log(ngx.ERR, "err:", err)
end

糖果

糖果
LUA从入门到放弃

Tweyseo Walkonluajit 1

# **0. 背景**## **a. 目的**这里主要研究LuaJIT的Trace的相关原理,并且展示如何使用LuaJIT提供的[v.lua](https://github.com/LuaJIT/LuaJIT/blob/master/src/jit/v.lua)和[dump...… Continue reading

Nginx+Lua中文WIKI

Published on March 14, 2019