No matching definitions.

valkey/cmd

src/valkey/cmd.tur

a single typed argument to `cmd`. The sum discriminates a

Since: 0.5.0 (U6)

defn

vk-str

(vk-str [s : cstr] :)

wrap a string as a typed command argument.

Since: 0.5.0 (U6)

defn

vk-int

(vk-int [n : int] :)

wrap an integer as a typed command argument. The value is

Since: 0.5.0 (U6)

defn

vk-bytes

(vk-bytes [p : cstr len : int] :)

wrap a (pointer, length) pair as a binary-safe argument.

Since: 0.5.0 (U6)

defn

cmd

(cmd [^borrow c : Client command : cstr args : ValkeyArg] :)

send an arbitrary command with typed variadic arguments.

cctx-ptr (ok-val from client-connect)
commandcommand name string (e.g. "SET")
argszero or more `ValkeyArg` values

(ok reply-ptr) on success; (err 0) on error or NULL reply. Call reply-free on the reply-ptr when done.

(let [r (cmd c "SET" (vk-str "mykey") (vk-str "myval"))]
    (if (ok? r) (reply-free (ok-val r)) (println "cmd failed")))
  (cmd c "EXPIRE" (vk-str "mykey") (vk-int 60))
  (cmd c "SET" (vk-str "blob") (vk-bytes payload n))

Since: VK0 (typed variadic surface in 0.5.0 / U6)

defn

cmd-get

(cmd-get [^borrow c : Client key : cstr] :)

send GET key.

cctx-ptr (ok-val from client-connect)
keykey name string

(ok reply-ptr) on success; (err 0) on error. Call reply-free on the reply-ptr when done.

(let [r (cmd-get c "mykey")]
    (if (ok? r) (println (reply-string (ok-val r))) (println "get failed")))

Since: VK0

defn

cmd-set

(cmd-set [^borrow c : Client key : cstr val : cstr] :)

send SET key value.

cctx-ptr (ok-val from client-connect)
keykey name string
valvalue string

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-set c "mykey" "hello")]
    (if (ok? r) (reply-free (ok-val r)) (println "set failed")))

Since: VK0

defn

cmd-del

(cmd-del [^borrow c : Client key : cstr] :)

send DEL key.

cctx-ptr (ok-val from client-connect)
keykey name string

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-del c "mykey")]
    (if (ok? r) (reply-free (ok-val r)) (println "del failed")))

Since: VK0

defn

cmd-incr

(cmd-incr [^borrow c : Client key : cstr] :)

send INCR key.

cctx-ptr (ok-val from client-connect)
keykey name string

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-incr c "counter")]
    (if (ok? r) (println (reply-int (ok-val r))) (println "incr failed")))

Since: VK0

defn

cmd-expire

(cmd-expire [^borrow c : Client key : cstr seconds : cstr] :)

send EXPIRE key seconds.

cctx-ptr (ok-val from client-connect)
keykey name string
secondsexpiry duration as a decimal string (e.g. "60")

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-expire c "session" "3600")]
    (if (ok? r) (reply-free (ok-val r)) (println "expire failed")))

Since: VK0

defn

cmd-hset

(cmd-hset [^borrow c : Client hash : cstr field : cstr val : cstr] :)

send HSET hash field value.

cctx-ptr (ok-val from client-connect)
hashhash key name
fieldfield name within the hash
valvalue string

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-hset c "user:1" "name" "Alice")]
    (if (ok? r) (reply-free (ok-val r)) (println "hset failed")))

Since: VK0

defn

cmd-hget

(cmd-hget [^borrow c : Client hash : cstr field : cstr] :)

send HGET hash field.

cctx-ptr (ok-val from client-connect)
hashhash key name
fieldfield name within the hash

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-hget c "user:1" "name")]
    (if (ok? r) (println (reply-string (ok-val r))) (println "hget failed")))

Since: VK0

defn

cmd-lpush

(cmd-lpush [^borrow c : Client list : cstr val : cstr] :)

send LPUSH list value.

cctx-ptr (ok-val from client-connect)
listlist key name
valvalue string to prepend

(ok reply-ptr) on success; (err 0) on error.

(let [r (cmd-lpush c "mylist" "item")]
    (if (ok? r) (reply-free (ok-val r)) (println "lpush failed")))

Since: VK0

defn

cmd-lrange

(cmd-lrange [^borrow c : Client list : cstr start : int stop : int] :)

send LRANGE list start stop.

cctx-ptr (ok-val from client-connect)
listlist key name
start0-based start index (inclusive)
stop0-based stop index (inclusive; -1 for last element)

(ok reply-ptr) on success; (err 0) on error. Reply type is array; use reply-array-len and reply-array-get to iterate.

(let [r (cmd-lrange c "mylist" 0 -1)]
    (if (ok? r) (let [rep (ok-val r)] ...) (println "lrange failed")))

Since: VK0

Internal definitions
__cmd-impl-- fixed-arity worker behind the variadic `cmd`. Walks the