Skip to content

Commit 2730b65

Browse files
committed
数据库选择 权限验证
1 parent cdbc0ee commit 2730b65

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Lua-Nginx/redis-livenode/set_by_file.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ if not ok then
1616
return err
1717
end
1818

19+
-- 权限验证
20+
local res,err = redis_instance:auth('tinywanredis')
21+
if not res then
22+
ngx.say("failed to authenticate: ", err)
23+
return
24+
end
25+
26+
--数据库选择
27+
redis_instance:select(1)
28+
1929
--调用API获取数据
2030
local resp, err = redis_instance:hget("liveNodeRedis:"..stream_a,'liveNode')
2131
if not resp then
@@ -28,7 +38,7 @@ if resp == ngx.null then
2838
ngx.say("this is not redis_data") --比如默认值
2939
return nil
3040
end
31-
-- 赋值给ngx 变量为当前Redis查询结果
3241
ngx.var.stream_id = resp
42+
-- ngx.say("reds get result : ", resp)
3343

3444

0 commit comments

Comments
 (0)