valkey/client
src/valkey/client.tur
defn
client-connect
(client-connect [host :cstr port :int] :ptr<void>)
connect to a Valkey/Redis server over TCP.
Parameters
| host | hostname or IP address string | |
| port | TCP port number |
Returns
(ok ctx-ptr) on success; (err 0) on failure. ctx-ptr is an opaque :int handle; pass to cmd/reply/pubsub functions. Call client-close when done.
Example
(let [r (client-connect "127.0.0.1" 6379)]
(if (ok? r) (let [c (ok-val r)] ...) (println "connect failed")))
Since: VK0
defn
client-connect-unix
(client-connect-unix [path :cstr] :ptr<void>)
connect to a Valkey/Redis server over a Unix socket.
Parameters
| path | filesystem path to the Unix domain socket |
Returns
(ok ctx-ptr) on success; (err 0) on failure.
Example
(let [r (client-connect-unix "/tmp/valkey.sock")]
(if (ok? r) (let [c (ok-val r)] ...) (println "connect failed")))
Since: VK0
defn
client-close
(client-close [c :int] :void)
close a connection and free its resources.
Parameters
| c | ctx-ptr obtained from client-connect or client-connect-unix (ok-val) |
Returns
void
Example
(client-close c)
Since: VK0
defn
client-ping
(client-ping [c :int] :ptr<void>)
send a PING command and verify the server responds.
Parameters
| c | ctx-ptr (ok-val from client-connect) |
Returns
(ok 0) if the server replies with a status reply; (err 0) otherwise.
Example
(let [r (client-ping c)]
(if (ok? r) (println "pong") (println "ping failed")))
Since: VK0
Internal definitions
__ok-- create an ok result wrapping integer value v.__err-- create an err result wrapping integer error value e.