redis — Lilush API

←index

Overview

Async Redis client using the lev event loop. Must be called within lev.run().

Submodules

ModuleDescription
redis.respShared RESP2 protocol encoding/decoding and Redis connection config validation.

Functions

NameSignature
client:cmdclient:cmd(...) -> result, err
client:pipelineclient:pipeline(commands) -> results, err
client:readclient:read() -> response, err
client:closeclient:close(no_keepalive) -> ok
connectconnect(config) -> client, err

client:cmd(...) -> result, err

Execute a Redis command and return the parsed response

client:pipeline(commands) -> results, err

Execute multiple Redis commands in a single round-trip (pipelining)

Sends all commands at once and reads all responses. Each entry in commands is an array of arguments (same as cmd varargs). Returns an array of result tables { value, err } in the same order.

client:read() -> response, err

Read a raw RESP response from the connection

client:close(no_keepalive) -> ok

Close the Redis connection

Closes the connection. By default the underlying socket is returned to the connection pool for reuse. Pass true to force-close the socket instead of pooling it. The socket is also force-closed when the pool exceeds its size limit.

connect(config) -> client, err

Connect to a Redis server asynchronously

Establishes an async connection to a Redis server, returning a client object. Must be called within lev.run().

config, when provided, can be either a string URL, or a table.