docs/migration-guides/v6-to-v7.md
This guide helps you migrate from Jedis 6.2.0 to Jedis 7.0.0. Version 7.0.0 includes several breaking changes focused on removing deprecated features and improving the API design.
Jedis 7.0.0 is a major release that removes previously deprecated features and modernizes the API. The main focus areas are:
The following classes and features have been completely removed in Jedis 7.0.0:
JedisSharding - Use JedisCluster for distributed Redis deployments insteadShardedPipeline - Use Pipeline with JedisCluster insteadShardedConnectionProvider - No replacement neededShardedCommandArguments - Internal class, no replacement neededShardedCommandObjects - Internal class, no replacement neededIf you were using JedisSharding:
Before (v6.2.0):
List<HostAndPort> shards = Arrays.asList(
new HostAndPort("localhost", 6379),
new HostAndPort("localhost", 6380)
);
JedisSharding jedisSharding = new JedisSharding(shards);
jedisSharding.set("key", "value");
After (v7.0.0):
// Option 1: Use JedisCluster for distributed deployments
Set<HostAndPort> nodes = new HashSet<>(Arrays.asList(
new HostAndPort("localhost", 6379),
new HostAndPort("localhost", 6380)
));
JedisCluster jedisCluster = new JedisCluster(nodes);
jedisCluster.set("key", "value");
// Option 2: Use JedisPooled for single-node deployments
JedisPooled jedis = new JedisPooled("localhost", 6379);
jedis.set("key", "value");
Several base classes have been renamed to better reflect their purpose:
PipelineBase has been removedPipeline now extends AbstractPipeline insteadImpact: If you were using PipelineBase as a type reference, change it to AbstractPipeline.
Before (v6.2.0):
PipelineBase pipeline = jedis.pipelined();
After (v7.0.0):
AbstractPipeline pipeline = jedis.pipelined();
// Or use the concrete type:
Pipeline pipeline = (Pipeline) jedis.pipelined();
TransactionBase has been removedTransaction now extends AbstractTransaction insteadImpact: If you were using TransactionBase as a type reference, change it to AbstractTransaction.
Before (v6.2.0):
TransactionBase transaction = jedis.multi();
After (v7.0.0):
AbstractTransaction transaction = jedis.multi();
// Or use the concrete type:
Transaction transaction = (Transaction) jedis.multi();
Several deprecated constructors have been removed from UnifiedJedis:
Cluster constructors with maxAttempts:
// REMOVED in v7.0.0
UnifiedJedis(Set<HostAndPort> nodes, JedisClientConfig config, int maxAttempts)
UnifiedJedis(Set<HostAndPort> nodes, JedisClientConfig config, int maxAttempts, Duration maxTotalRetriesDuration)
UnifiedJedis(Set<HostAndPort> nodes, JedisClientConfig config, GenericObjectPoolConfig<Connection> poolConfig, int maxAttempts, Duration maxTotalRetriesDuration)
Sharding constructors:
// REMOVED in v7.0.0
UnifiedJedis(ShardedConnectionProvider provider)
UnifiedJedis(ShardedConnectionProvider provider, Pattern tagPattern)
Before (v6.2.0):
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("localhost", 6379));
JedisClientConfig config = DefaultJedisClientConfig.builder().build();
UnifiedJedis jedis = new UnifiedJedis(nodes, config, 3);
After (v7.0.0):
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("localhost", 6379));
JedisClientConfig config = DefaultJedisClientConfig.builder().build();
// Use JedisCluster instead
JedisCluster jedis = new JedisCluster(nodes, config);
// Or use the new builder pattern
JedisCluster jedis = JedisCluster.builder()
.nodes(nodes)
.clientConfig(config)
.build();
The return type has been changed to be more generic:
Before (v6.2.0):
PipelineBase pipelined()
After (v7.0.0):
AbstractPipeline pipelined()
Impact: Minimal - AbstractPipeline is the parent class, so existing code should continue to work.
Jedis 7.0.0 significantly refactors the automatic failover and failback API. If you were using the failover features in v6.2.0 with MultiClusterClientConfig and MultiClusterPooledConnectionProvider, these have been renamed and improved in v7.0.0.
For detailed migration guidance on automatic failover and failback please refer to the Automatic Failover and Failback Migration Guide.
Jedis 7.0.0 introduces a fluent builder pattern for creating client instances, making configuration more intuitive and discoverable.
New in v7.0.0:
JedisPooled jedis = JedisPooled.builder()
.hostAndPort("localhost", 6379)
.clientConfig(DefaultJedisClientConfig.builder()
.user("myuser")
.password("mypassword")
.database(0)
.build())
.poolConfig(new GenericObjectPoolConfig<>())
.build();
New in v7.0.0:
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("localhost", 7000));
nodes.add(new HostAndPort("localhost", 7001));
JedisCluster cluster = JedisCluster.builder()
.nodes(nodes)
.clientConfig(DefaultJedisClientConfig.builder()
.password("mypassword")
.build())
.maxAttempts(5)
.maxTotalRetriesDuration(Duration.ofSeconds(10))
.build();
New in v7.0.0:
Set<HostAndPort> sentinels = new HashSet<>();
sentinels.add(new HostAndPort("localhost", 26379));
sentinels.add(new HostAndPort("localhost", 26380));
JedisSentineled jedis = JedisSentineled.builder()
.masterName("mymaster")
.sentinels(sentinels)
.clientConfig(DefaultJedisClientConfig.builder()
.password("mypassword")
.build())
.build();
If you encounter issues during migration create an issue or start a discussion.