{"action":"created","issue":{"url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/78","repository_url":"https://api.github.com/repos/openresty/lua-resty-redis","labels_url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/78/comments","events_url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/78/events","html_url":"https://github.com/openresty/lua-resty-redis/issues/78","id":140857420,"number":78,"title":"failed to set keepalive: connection in dubious state","user":{"login":"hcaihao","id":3926845,"avatar_url":"https://avatars.githubusercontent.com/u/3926845?v=3","gravatar_id":"","url":"https://api.github.com/users/hcaihao","html_url":"https://github.com/hcaihao","followers_url":"https://api.github.com/users/hcaihao/followers","following_url":"https://api.github.com/users/hcaihao/following{/other_user}","gists_url":"https://api.github.com/users/hcaihao/gists{/gist_id}","starred_url":"https://api.github.com/users/hcaihao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcaihao/subscriptions","organizations_url":"https://api.github.com/users/hcaihao/orgs","repos_url":"https://api.github.com/users/hcaihao/repos","events_url":"https://api.github.com/users/hcaihao/events{/privacy}","received_events_url":"https://api.github.com/users/hcaihao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-15T02:59:48Z","updated_at":"2016-03-16T10:30:51Z","closed_at":null,"body":"local redis = require \"resty.redis\"\r\nlocal red = redis:new()\r\n\r\nred:set_timeout(1000) -- 1 sec\r\n\r\nlocal ok, err = red:connect(\"127.0.0.1\", 6379)\r\nif not ok then\r\n    ngx.say(\"failed to connect: \", err)\r\n    return\r\nend\r\n\r\n--ngx.say(\"connected to redis.\")\r\n\r\n\r\nlocal key = \"testkey\"\r\nred:set(key, false)\r\n\r\nlocal ok, err = red:set_keepalive(10000, 100)\r\nif not ok then\r\n\tngx.say(\"failed to set keepalive: \", err)\r\n\treturn\r\nend\r\n\r\n\r\nThe code bellow throw an error: \"failed to set keepalive: connection in dubious state\"\r\n\r\n\r\nI know redis set support string value only, But \"red:set(key, true)\" will be ok, why?"},"comment":{"url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/comments/197252030","html_url":"https://github.com/openresty/lua-resty-redis/issues/78#issuecomment-197252030","issue_url":"https://api.github.com/repos/openresty/lua-resty-redis/issues/78","id":197252030,"user":{"login":"agentzh","id":56241,"avatar_url":"https://avatars.githubusercontent.com/u/56241?v=3","gravatar_id":"","url":"https://api.github.com/users/agentzh","html_url":"https://github.com/agentzh","followers_url":"https://api.github.com/users/agentzh/followers","following_url":"https://api.github.com/users/agentzh/following{/other_user}","gists_url":"https://api.github.com/users/agentzh/gists{/gist_id}","starred_url":"https://api.github.com/users/agentzh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agentzh/subscriptions","organizations_url":"https://api.github.com/users/agentzh/orgs","repos_url":"https://api.github.com/users/agentzh/repos","events_url":"https://api.github.com/users/agentzh/events{/privacy}","received_events_url":"https://api.github.com/users/agentzh/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T10:30:50Z","updated_at":"2016-03-16T10:30:50Z","body":"@hcaihao This is because the Lua `false` value maps to the redis NULL value on the protocol level, which is not supported by the redis set command at all and thus results in an error returned. That's why you should always handle any errors properly yourself.\r\n\r\n@doujiang24 I'm not sure about that. We could raise an exception for this particular case but I still think people should always check return values of the redis queries anyway."}}