Client libraries
Azure Cache for Redis is based on the popular open-source in-memory data store, open-source Redis. Azure Cache for Redis can be accessed by a wide variety of Redis clients for many programming languages. Each client library has its own API that makes calls to Redis server using Redis commands, but the client libraries are built to talk to any Redis server.
Each client maintains its own reference documentation for its library. The clients also provide links to get support through the client library developer community. The Azure Cache for Redis team doesn't own the development, or the support for any client libraries.
Although we don't own or support any client libraries, we do recommend some libraries. Recommendations are based on popularity and whether there's an active online community to support and answer your questions. We only recommend using the latest available version, and upgrading regularly as new versions become available. These libraries are under active development and often release new versions with improvements to reliability and performance.
Client library | Language | GitHub repo | Documentation |
---|---|---|---|
StackExchange.Redis | C#/.NET | Link | More information here |
Lettuce | Java | Link | More information here |
Jedis | Java | Link | |
node_redis | Node.js | Link | |
Redisson | Java | Link | More information here |
ioredis | Node.js | Link | More information here |
Note
Your application can use any client library that is compatible with open-source Redis to connect to your Azure Cache for Redis instance.
Client library-specific guidance
For information on client library-specific guidance best practices, see the following links:
- StackExchange.Redis (.NET)
- Java - Which client should I use?
- Lettuce (Java)
- Jedis (Java)
- Redisson (Java)
- Node.js
- PHP
- HiRedisCluster
- ASP.NET Session State Provider
Redisson (Java)
We recommend you use redisson 3.14.1 or higher. Older versions contain known connection leak issues that cause problems after failovers. Monitor the Redisson changelog for other known issues can affect features used by your application. For more information, seeCHANGELOG
and the Redisson FAQ.
Other notes:
- Redisson defaults to 'read from replica' strategy, unlike some other clients. To change this, modify the 'readMode' config setting.
- Redisson has a connection pooling strategy with configurable minimum and maximum settings, and the default minimum values are large. The large defaults could contribute to aggressive reconnect behaviors or 'connection storms'. To reduce the risk, consider using fewer connections because you can efficiently pipeline commands, or batches of commands, over a few connections.
- Redisson has a default idle connection timeout of 10 seconds, which leads to more closing and reopening of connections than ideal.
Here's a recommended baseline configuration for cluster mode that you can modify as needed:
clusterServersConfig:
idleConnectionTimeout: 30000
connectTimeout: 15000
timeout: 5000
retryAttempts: 3
retryInterval: 3000
checkLockSyncedSlaves: false
failedSlaveReconnectionInterval: 15000
failedSlaveCheckInterval: 60000
subscriptionsPerConnection: 5
clientName: "redisson"
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 2
slaveConnectionPoolSize: 24
masterConnectionMinimumIdleSize: 2
masterConnectionPoolSize: 24
readMode: "MASTER"
subscriptionMode: "MASTER"
nodeAddresses:
- "redis://mycacheaddress:6380"
scanInterval: 1000
pingConnectionInterval: 60000
keepAlive: false
tcpNoDelay: true
For an article demonstrating how to use Redisson's support for JCache as the store for HTTP session state in IBM Liberty on Azure, see Use Java EE JCache with Open Liberty or WebSphere Liberty on an Azure Kubernetes Service (AKS) cluster.
How to use client libraries
Besides the reference documentation, you can find tutorials showing how to get started with Azure Cache for Redis using different languages and cache clients.
For more information on using some of these client libraries in tutorials, see the following articles:
- Code a .NET Framework app
- Code a .NET Core app
- Code an ASP.NET web app
- Code an ASP.NET Core web app
- Code a Java app
- Code a Node.js app
- Code a Python app