Created
January 27, 2021 15:55
-
-
Save un-def/82d80ab525383cdb2ed868bb984e717a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local tcp_sock_mt = getmetatable(ngx.socket.tcp()) | |
local udp_sock_mt = getmetatable(ngx.socket.udp()) | |
local is_socket_object = function(obj) | |
local obj_mt = getmetatable(obj) | |
return obj_mt == tcp_sock_mt or obj_mt == udp_sock_mt | |
end | |
-------- | |
local redis = require('resty.redis') | |
local client = redis:new() | |
ngx.say(is_socket_object(client)) -- false | |
ngx.say(is_socket_object('string')) -- false | |
ngx.say(is_socket_object(client._sock)) -- true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/65895230/why-doesnt-resty-redis-work-with-the-ngx-timer/65906836