CLIENT LIST returns information and statistics about the client connections server in a mostly human readable format as @babak stated in the answer.
If you just need to get total number of connections
you may use INFO command. INFO clients
will print something like this and connected_clients
would be what you are looking for.
# Clients
connected_clients:2
client_recent_max_input_buffer:8
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0
The following code do the work;
const Redis = require("ioredis");
const redis = new Redis();
async function clients() {
console.log(await redis.info('clients'));
}
clients();