请看示例代码(注意 data 的数组下标): -- http://www.kyne.com.au/~mark/software/lua-cjson.php-- version: 2.1 devellocal json = require("cjson")local data = {1, 2}data[1000] = 99-- ... do the other thingsngx.say(json.encode(data))运行日志报错结果: 2015/06/27 00:23:13 [error] 2714#0: *40 lua entry thread aborted: runtime error: ...
先看一下官方的调用示例代码:local redis = require "resty.redis"local red = redis:new()red:set_timeout(1000) -- 1 sec-- or connect to a unix domain socket file listened-- by a redis server:-- local ok, err = red:connect("unix:/path/to/redis.sock")local ok, err = red:connect("127.0.0.1", 6379)if not ok then ngx.