2
我正在使用Lua + nginx與OpenResty捆綁。但是當我嘗試將Lua腳本與Redis連接時,問題就出現了,我無法連接成功。我經歷了很多鏈接和博客,但最終總是失敗。這是我正在嘗試的代碼片段。如果有人有經驗或我做錯了什麼,請幫助我。有誰知道如何在Redis中使用Lua?
server {
location /test {
content_by_lua '
local redis = require "resty.redis" // **Problem in code "Not able to 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.say("failed to connect: ", err)
return
end
}
}
是'/ usr/local/openresty/lualib/resty/redis.lua'能找到嗎? – fannheyward 2015-04-02 08:51:01