What Is New in Jedis 2.2
Jedis 2.2 delivers a significant update focused on modern Redis features and enhanced stability. This release introduces support for Redis ACL, improves connection handling, and resolves several critical bugs from previous versions.
| Category | Key Changes |
|---|---|
| New Features | Redis ACL support, RedisGraph module support, JSON commands |
| Improvements | Connection and pipeline resilience, URI handling, error messages |
| Bug Fixes | Cluster command routing, thread safety, connection leaks |
| Deprecated | Legacy BinaryJedis constructor |
How does Jedis 2.2 handle Redis ACL?
Jedis 2.2 adds first-class support for Redis 6's Access Control List (ACL) system. You can now authenticate using a username and password combination instead of just a password.
This is implemented through a new user parameter in the connection URI and updated client constructors. In practice, this means you can integrate with secured Redis instances that have multiple users and fine-grained permissions.
Code Example
// Connecting with ACL user and password
Jedis jedis = new Jedis("redis://myuser:mypassword@localhost:6379/0");
// Or using the new constructor
Jedis jedis = new Jedis("localhost", 6379, DefaultJedisClientConfig.builder()
.user("myuser")
.password("mypassword")
.build());
What connection improvements were made?
The connection handling has been made more robust, especially for clustered environments and pipelines. This addresses edge cases where connections could get stuck or leak under heavy load.
They fixed an issue where a java.util.ConcurrentModificationException could be thrown during connection management. This matters because it prevents crashes in multi-threaded applications that share Jedis instances across threads.
Which Redis modules are now supported?
This release expands module support with commands for RedisGraph. You can now execute Cypher queries directly through Jedis for graph operations.
Support for JSON commands via the RedisJSON module was also added. This allows you to work with JSON documents stored in Redis without needing low-level extensions.
Code Example
// Using RedisGraph module
GraphCommands graph = jedis.graph();
graph.query("myGraph", "CREATE (:Person {name: 'John'})");
// Using JSON commands
JSONCommands json = jedis.json();
json.set("user:1", "$", "{\"name\":\"Alice\",\"age\":30}");
What breaking changes should I watch for?
The main breaking change is the deprecation of the BinaryJedis constructor that accepted only host and port parameters. You'll need to use the updated constructor that takes a JedisClientConfig object instead.
Some internal exception types were also changed from checked exceptions to runtime exceptions. This simplifies error handling but might require updates to existing catch blocks that were looking for specific exception types.
FAQ
How do I connect to a Redis 6+ instance with ACL using Jedis 2.2?
Use the new connection URI format that includes the username: redis://username:password@host:port or the updated DefaultJedisClientConfig builder with the .user() method.
Does Jedis 2.2 fix the cluster command routing issues?
Yes, several fixes address improper command routing in cluster mode, particularly for commands like BITOP and BRPOPLPUSH that were previously sent to wrong nodes.
Can I use RedisJSON with Jedis 2.2?
Absolutely. The update adds support for RedisJSON commands through the JSONCommands interface, allowing full CRUD operations on JSON documents stored in Redis.
What should I replace the deprecated BinaryJedis constructor with?
Migrate to using new BinaryJedis(host, port, DefaultJedisClientConfig.builder().build()) instead of the simple new BinaryJedis(host, port) constructor.
Is thread safety improved in this release?
Yes, fixes for ConcurrentModificationException and connection pool handling make threaded environments more stable, though you should still use connection pooling for production applications.