Skip to content

Commit

Permalink
feature: set_timeout() now returns the result of the operation. thank…
Browse files Browse the repository at this point in the history
…s Guanlan Dai for the report.
  • Loading branch information
agentzh committed Aug 28, 2014
1 parent 7975df1 commit ce28d24
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Expand Up @@ -201,10 +201,12 @@ The `flags` parameter is optional, defaults to `0`.

set_timeout
----------
`syntax: memc:set_timeout(time)`
`syntax: ok, err = memc:set_timeout(time)`

Sets the timeout (in ms) protection for subsequent operations, including the `connect` method.

Returns 1 when successful and nil plus a string describing the error otherwise.

[Back to TOC](#table-of-contents)

set_keepalive
Expand Down
3 changes: 2 additions & 1 deletion lib/resty/memcached.lua
Expand Up @@ -56,7 +56,8 @@ function _M.set_timeout(self, timeout)
return nil, "not initialized"
end

return sock:settimeout(timeout)
sock:settimeout(timeout)
return 1
end


Expand Down
2 changes: 1 addition & 1 deletion t/sanity.t
Expand Up @@ -30,7 +30,7 @@ __DATA__
local memcached = require "resty.memcached"
local memc = memcached:new()
memc:set_timeout(1000) -- 1 sec
assert(memc:set_timeout(1000)) -- 1 sec
local ok, err = memc:connect("127.0.0.1", $TEST_NGINX_MEMCACHED_PORT)
if not ok then
Expand Down

0 comments on commit ce28d24

Please sign in to comment.