Tair is fully compatible with open source Redis. You can connect to Tair in the same manner as you connect to open source Redis. Therefore, you can use any Redis-compliant client to connect to a Tair instance.
Prerequisites
The operations listed in the following table are performed based on the type of the host on which the client is deployed.
Host | Operation |
ECS instance (recommended) |
|
On-premises device |
|
Usage notes
By default, cluster and read/write splitting instances run in proxy mode. In this mode, you can connect to such a Tair instance by using the endpoint of a proxy node in the instance in the same manner as you connect to a standard instance. For more information about cluster and read/write splitting instances, see Cluster architecture and Read/write splitting architecture.
NoteIf you use a private endpoint to connect to a Tair cluster instance, you can connect to the instance in the same manner as you connect to an open source Redis cluster. For more information about private endpoints, see Enable the direct connection mode.
If password-free access is enabled for a Tair instance deployed in a VPC, clients that are located in the same VPC as the instance can connect to the instance without using passwords. For more information, see Enable password-free access.
Obtain connection information
When you use a client to connect to a Tair instance, you must obtain the connection information described in the following table and specify the information in the code.
Item | Description |
Instance endpoint | Tair instances support multiple endpoint types. We recommend that you use VPCs for higher security and lower network latency. For more information, see View endpoints and port numbers. |
Port number | The default port number is 6379. You can also use a custom port number. For more information, see Change the endpoint or port of a Tair instance. |
Instance account (optional for specific clients) | By default, a Tair instance has a database account that is named after the instance ID. Example: r-bp10noxlhcoim2****. You can create another database account and grant the required permissions to the account. For more information, see Create and manage database accounts. |
Password | The password format varies based on the selected account:
Note
|
Sample code for common clients
Tair supports all clients that are supported by open source Redis. For more information, see Connect with Redis clients. This section provides sample code on how to use common clients to connect to Tair.