1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-01 16:46:54 +03:00

Add connection status check example and documentation. (#2340)

* Adds example for transactions with arbitrary commands.

* Formatting.

* Adds isReady doc and example for isReady and isOpen.

* Improved example.

* Added isOpen explanation.

* Removed example from a different PR.
This commit is contained in:
Simon Prickett
2022-12-13 20:19:45 +00:00
committed by GitHub
parent 118dc11191
commit da3face951
3 changed files with 57 additions and 25 deletions

View File

@ -64,6 +64,8 @@ createClient({
You can also use discrete parameters, UNIX sockets, and even TLS to connect. Details can be found in the [client configuration guide](./docs/client-configuration.md).
To check if the the client is connected and ready to send commands, use `client.isReady` which returns a boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example when the client is still connecting or reconnecting after a network error).
### Redis Commands
There is built-in support for all of the [out-of-the-box Redis commands](https://redis.io/commands). They are exposed using the raw Redis command names (`HSET`, `HGETALL`, etc.) and a friendlier camel-cased version (`hSet`, `hGetAll`, etc.):