ApsaraDB for Redis is fully compatible with open source Redis. You can connect to ApsaraDB for Redis in the same manner as you connect to open source Redis. Therefore, you can use any Redis-compliant client to connect to an ApsaraDB for Redis 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 an ApsaraDB for Redis instance by using the endpoint of a proxy node in the instance in the same manner as you connect to an ApsaraDB for Redis standard instance. For more information about cluster and read/write splitting instances, see Cluster master-replica instances and Read/write splitting instances.
NoteIf you use a private endpoint to connect to an ApsaraDB for Redis 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 an ApsaraDB for Redis instance deployed in a VPC, a client 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 an ApsaraDB for Redis instance, you must obtain the connection information described in the following table and specify the information in the code.
Item | Description |
Instance endpoint | ApsaraDB for Redis instances support multiple endpoint types. We recommend that you use VPC endpoints for higher security and lower network latency. For more information, see View endpoints. |
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 number of an instance. |
Instance account (optional for specific clients) | By default, an ApsaraDB for Redis 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
|
Common types of clients
For a complete list of Redis-compliant clients, see Redis Clients.
This section provides only sample code on how to use common clients to connect to ApsaraDB for Redis. For information about how to use a client to connect to ApsaraDB for Redis Enhanced Edition (Tair), see Use a client to connect to a Tair instance.