Skip to content

redis中的值不存在,返回值的疑惑 #12

Open
@jeffbmob

Description

@jeffbmob
--测试代码
local redis = require "redis-util"
local redis_host = "10.10.10.177"
local redis_port = 6379

local red =
redis:new(
{
    host = redis_host,
    port = redis_port,
    db_index = 0,
    password = nil,
    timeout = 1000,
    keepalive = 60000,
    pool_size = 100
}
)

local res, err = red:get("dog111")
if not res then
    ngx.log(ngx.DEBUG, "failed to get dog: ", err)
end

if res == ngx.null then
    ngx.log(ngx.DEBUG, "ngx.null")
end

if res == nil then
    ngx.log(ngx.DEBUG, "nil")
end

输出值:

route.lua:26: failed to get dog: nil
route.lua:36: nil

按照文档,如果返回值不存在,res应该是ngx.null,但在这个代码中,res的值是nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions