sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 349 forks source link

[QUESTION]How can I determine whether the connection to Redis is successful? #607

Open daizhichao opened 2 days ago

daizhichao commented 2 days ago

Is it necessary to use the ping() function to determine whether the connection is successful? As shown in the figure, an exception indicating a connection failure will be thrown only after using the ping() function.

daizhichao commented 2 days ago

QQ20241111-162325

sewenew commented 1 day ago

The connection is lazily created, i.e. when you send command to Redis server, redis++ creates a connection to it.

If you want to check if the given <host, port> pair works, you can manually send a ping command.

Regards