valkey/client
src/valkey/client.tur
defopaque
Client
(Client)
Valkey/Redis connection handle.
Since: 0.2.0
defn
client-connect
(client-connect [host : cstr port : int] :)
connect to a Valkey/Redis server over TCP.
Parameters
| host | hostname or IP address string | |
| port | TCP port number |
Returns
(Result Client int) -- ok carries the Client handle; err carries 0 on failure. 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] :)
connect to a Valkey/Redis server over a Unix socket.
Parameters
| path | filesystem path to the Unix domain socket |
Returns
(Result Client int) -- ok carries the Client handle; err carries 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 : Client] :)
close a connection and free its resources.
Parameters
| c | ctx-ptr obtained from client-connect or client-connect-unix (ok-val). | |
| Consumes the linear Client: its single legal consumption, so any | ||
| later use of the handle is rejected under -Xsubstructural. |
Returns
void
Example
(client-close c)
Since: VK0
defn
client-ping
(client-ping [^borrow c : Client] :)
send a PING command and verify the server responds.
Parameters
| c | ctx-ptr (ok-val from client-connect) |
Returns
(Result int int) -- ok carries 0 if the server replies with a status reply; err carries 0 otherwise.
Example
(let [r (client-ping c)]
(if (ok? r) (println "pong") (println "ping failed")))
Since: VK0