Created
April 27, 2023 06:29
-
-
Save haolian9/1ebe945da6c6c5ad3a849b20217c02c8 to your computer and use it in GitHub Desktop.
send ping to redis from nvim's lua runtime
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 uv = vim.loop | |
local sock = assert(uv.new_pipe()) | |
uv.pipe_connect(sock, "/run/user/1000/redis.sock", function(err) assert(err == nil, err) end) | |
uv.read_start(sock, function(err, data) | |
if err then | |
print("read error", err) | |
elseif data then | |
print("read data", data) | |
-- oneshot | |
uv.close(sock) | |
else | |
print("sock closed") | |
end | |
end) | |
uv.write(sock, "*1\r\n$4\r\nping\r\n", function(err) assert(err == nil, err) end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment