run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<int> run() => withApp((app) async {
final client = Redis.connection(_connection(this));
try {
final watch = Stopwatch()..start();
final pong = await client.command(['PING']);
final ms = watch.elapsedMicroseconds / 1000;
final info = parseRedisInfo(await client.command(['INFO', 'server']));
final server = info.containsKey('valkey_version')
? 'Valkey ${info['valkey_version']}'
: 'Redis ${info['redis_version'] ?? '?'}';
stdout.writeln(
'$pong from ${client.config.redacted} ($server, '
'${client.config.mode.name}) in ${ms.toStringAsFixed(2)} ms',
);
return 0;
} on RedisConnectionException catch (error) {
stderr.writeln(error.message);
return 1;
}
});