Skip to main content

Description

Returns the provided message. This command is useful for testing and debugging.

Method Signature

echo(message: string): Promise<string>

Parameters

message
string
required
The message to echo back

Return Value

result
string
The exact message that was sent

Examples

Basic echo

const response = await redis.echo("Hello, Redis!");
console.log(response); // "Hello, Redis!"

Echo with special characters

const response = await redis.echo("Line 1\nLine 2\nLine 3");
console.log(response);
// Output:
// Line 1
// Line 2
// Line 3

Test connection with custom message

const testMessage = `Test at ${new Date().toISOString()}`;
const response = await redis.echo(testMessage);
console.log(response === testMessage); // true

Echo empty string

const response = await redis.echo("");
console.log(response); // ""
console.log(response.length); // 0

See Also

  • ping - Test server connection

Build docs developers (and LLMs) love