Skip to content

Instantly share code, notes, and snippets.

@haolian9
Created April 27, 2023 06:29
Show Gist options
  • Save haolian9/1ebe945da6c6c5ad3a849b20217c02c8 to your computer and use it in GitHub Desktop.
Save haolian9/1ebe945da6c6c5ad3a849b20217c02c8 to your computer and use it in GitHub Desktop.
send ping to redis from nvim's lua runtime
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