rad.api

A Redis client.

attach-callback

(attach-callback client cb & channels)
Given a client, a callback function, and any number of channels, attach a
callback function to each channel.

When a message is published into any of the channels, Rad calls the callback
function with the message.

bytes->str

(bytes->str bs)
Decode a byte array into a UTF-8 string.

client

(client & {:keys [host port decode send-timeout sendq-capacity], :or {host "localhost", port 6379, decode identity, send-timeout (Duration/ofSeconds 60), sendq-capacity 128}})
Connect to a Redis server.

Options:

  :host (string, default: "localhost")
    The hostname of the Redis server to connect to.

  :port (long, default: 6379)
    The port number of the Redis server to connect to.

  :decode (function, default: identity)
    A function of one argument that accepts a byte array and returns any
    value.

    Rad uses this function to decode all binary data that Redis sends it.

    To tell Rad to decode all byte arrays Redis sends it into UTF-8 strings,
    use rad.api/bytes->str.

  :sendq-capacity (long, default: 128)
    The maximum capacity of Rad's send queue.

    If this queue is full, calling the function this function returns blocks
    until there's room in the queue.

  :send-timeout (java.time.Duration, default: "PT1M")
    The duration to wait for availability in the send queue.

    If this duration expires, you're probably sending commands faster than
    Rad or Redis can handle them.

Returns a Redis client.

When called with zero arguments, closes the client and all resources it holds
on to.

When called with one or more arguments, executes Redis commands.

Blocks iff send queue is full.

detach-callback

(detach-callback client cb & channels)
Given a client, a callback function, and any number of channels, detach the
callback function from each channel.