|
| 1 | +# Jedis 6.0.0 Migration Guide |
| 2 | + |
| 3 | +This guide helps you migrate from Jedis 5.x to Jedis 6.0.0. Version 6.0.0 includes breaking changes focused on Redis 8.0 support, removal of deprecated modules, and improvements to the Search API. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Overview](#overview) |
| 8 | +- [Breaking Changes](#breaking-changes) |
| 9 | + - [Removed RedisGraph Support](#removed-redisgraph-support) |
| 10 | + - [Removed Triggers and Functions (RedisGears v2)](#removed-triggers-and-functions-redisgears-v2) |
| 11 | + - [Search Dialect Default Change](#search-dialect-default-change) |
| 12 | + - [FT.PROFILE Return Type Change](#ftprofile-return-type-change) |
| 13 | + - [COMMAND INFO Response Changes](#command-info-response-changes) |
| 14 | +- [New Features](#new-features) |
| 15 | + - [Redis 8.0 Support](#redis-80-support) |
| 16 | + - [SslOptions for Advanced SSL Configuration](#ssloptions-for-advanced-ssl-configuration) |
| 17 | + - [Token-Based Authentication](#token-based-authentication) |
| 18 | + - [New Hash Commands](#new-hash-commands) |
| 19 | + - [Search Warning Messages](#search-warning-messages) |
| 20 | +- [Additional Resources](#additional-resources) |
| 21 | + |
| 22 | +## Overview |
| 23 | + |
| 24 | +Jedis 6.0.0 is a major release that adds Redis 8.0 support and removes deprecated features. The main focus areas are: |
| 25 | + |
| 26 | +1. **Redis 8.0 compatibility** - Full support for Redis 8.0 features including built-in JSON, Search, and TimeSeries |
| 27 | +2. **Module deprecations** - Removal of RedisGraph and Triggers & Functions (RedisGears v2) support |
| 28 | +3. **Search API improvements** - Default dialect change and enhanced profiling responses |
| 29 | +4. **Security enhancements** - New SSL options and token-based authentication support |
| 30 | + |
| 31 | +## Breaking Changes |
| 32 | + |
| 33 | +### Removed RedisGraph Support |
| 34 | + |
| 35 | +RedisGraph module support has been completely removed from Jedis 6.0.0 as the module has been deprecated by Redis. |
| 36 | + |
| 37 | +#### Removed Classes and Interfaces |
| 38 | + |
| 39 | +All classes in the `redis.clients.jedis.graph` package have been removed: |
| 40 | + |
| 41 | +- `RedisGraphCommands` interface |
| 42 | +- `RedisGraphPipelineCommands` interface |
| 43 | +- `GraphCommandObjects` class |
| 44 | +- `GraphCache`, `GraphProtocol`, `GraphQueryParams` classes |
| 45 | +- `ResultSet`, `ResultSetBuilder`, `Record`, `Header`, `Statistics` classes |
| 46 | +- All entity classes: `Edge`, `Node`, `Path`, `Point`, `Property`, `GraphEntity` |
| 47 | + |
| 48 | +### Removed Triggers and Functions (RedisGears v2) |
| 49 | + |
| 50 | +Support for Triggers and Functions (RedisGears v2) has been removed from Jedis 6.0.0. |
| 51 | + |
| 52 | +#### Removed Classes and Interfaces |
| 53 | + |
| 54 | +All classes in the `redis.clients.jedis.gears` package have been removed: |
| 55 | + |
| 56 | +- `RedisGearsCommands` interface |
| 57 | +- `RedisGearsProtocol` class |
| 58 | +- `TFunctionListParams`, `TFunctionLoadParams` classes |
| 59 | +- Response classes: `FunctionInfo`, `FunctionStreamInfo`, `GearsLibraryInfo`, `StreamTriggerInfo`, `TriggerInfo` |
| 60 | + |
| 61 | +### Search Dialect Default Change |
| 62 | + |
| 63 | +**BREAKING:** The default search dialect has changed from server-side default to **DIALECT 2** (client-side override). |
| 64 | + |
| 65 | +#### Impact |
| 66 | + |
| 67 | +Starting with Jedis 6.0.0, all `FT.SEARCH` and `FT.AGGREGATE` commands automatically append `DIALECT 2` unless explicitly configured otherwise. This may affect query results if you were relying on DIALECT 1 behavior. |
| 68 | + |
| 69 | +#### Migration Path |
| 70 | + |
| 71 | +**Option 1: Accept DIALECT 2 (Recommended)** |
| 72 | + |
| 73 | +Review your search queries to ensure they work correctly with DIALECT 2. Most queries should work without changes. |
| 74 | + |
| 75 | +**Option 2: Revert to DIALECT 1** |
| 76 | + |
| 77 | +If you need to maintain DIALECT 1 behavior: |
| 78 | + |
| 79 | +```java |
| 80 | +JedisPooled jedis = new JedisPooled("redis://localhost:6379"); |
| 81 | + |
| 82 | +// Set default dialect to 1 |
| 83 | +jedis.setDefaultSearchDialect(1); |
| 84 | + |
| 85 | +// Now all search commands will use DIALECT 1 |
| 86 | +SearchResult result = jedis.ftSearch("idx:products", "@category:electronics"); |
| 87 | +``` |
| 88 | + |
| 89 | +### FT.PROFILE Return Type Change |
| 90 | + |
| 91 | +The return type of `FT.PROFILE` commands has changed from `Map<String, Object>` to a structured `ProfilingInfo` object. |
| 92 | + |
| 93 | +#### Changed Methods |
| 94 | + |
| 95 | +**Before (v5.x):** |
| 96 | +```java |
| 97 | +Map.Entry<SearchResult, Map<String, Object>> ftProfileSearch( |
| 98 | + String indexName, FTProfileParams profileParams, Query query); |
| 99 | + |
| 100 | +Map.Entry<AggregationResult, Map<String, Object>> ftProfileAggregate( |
| 101 | + String indexName, FTProfileParams profileParams, AggregationBuilder aggr); |
| 102 | +``` |
| 103 | + |
| 104 | +**After (v6.0.0):** |
| 105 | +```java |
| 106 | +Map.Entry<SearchResult, ProfilingInfo> ftProfileSearch( |
| 107 | + String indexName, FTProfileParams profileParams, Query query); |
| 108 | + |
| 109 | +Map.Entry<AggregationResult, ProfilingInfo> ftProfileAggregate( |
| 110 | + String indexName, FTProfileParams profileParams, AggregationBuilder aggr); |
| 111 | +``` |
| 112 | + |
| 113 | +### COMMAND INFO Response Changes |
| 114 | + |
| 115 | +The response format for `COMMAND INFO` has been updated to include subcommand details, making it compatible with Redis 7.0+ and Redis 8.0. |
| 116 | + |
| 117 | +#### Impact |
| 118 | + |
| 119 | +If you were parsing the `COMMAND INFO` response, you may need to update your code to handle the new structure that includes subcommand information. |
| 120 | + |
| 121 | +**Before (v5.x):** |
| 122 | +```java |
| 123 | +List<Object> commandInfo = jedis.commandInfo("SET"); |
| 124 | +// Returns basic command information |
| 125 | +``` |
| 126 | + |
| 127 | +**After (v6.0.0):** |
| 128 | +```java |
| 129 | +List<Object> commandInfo = jedis.commandInfo("SET"); |
| 130 | +// Returns command information including subcommand details |
| 131 | +// Compatible with Redis 7.0+ format |
| 132 | +``` |
| 133 | + |
| 134 | +## New Features |
| 135 | + |
| 136 | +### Redis 8.0 Support |
| 137 | + |
| 138 | +Jedis 6.0.0 adds full support for Redis 8.0, which includes built-in support for: |
| 139 | + |
| 140 | +- **JSON** - Native JSON data type (previously RedisJSON module) |
| 141 | +- **Search and Query** - Full-text search capabilities (previously RediSearch module) |
| 142 | +- **TimeSeries** - Time-series data support (previously RedisTimeSeries module) |
| 143 | + |
| 144 | +**Example:** |
| 145 | +```java |
| 146 | +JedisPooled jedis = new JedisPooled("redis://localhost:6379"); |
| 147 | + |
| 148 | +// JSON operations (built-in in Redis 8.0) |
| 149 | +jedis.jsonSet("user:1", Path2.of("$"), "{\"name\":\"John\",\"age\":30}"); |
| 150 | +String json = jedis.jsonGet("user:1"); |
| 151 | + |
| 152 | +// Search operations (built-in in Redis 8.0) |
| 153 | +jedis.ftCreate("idx:users", |
| 154 | + FTCreateParams.createParams() |
| 155 | + .on(IndexDataType.JSON) |
| 156 | + .addPrefix("user:"), |
| 157 | + TextField.of("$.name").as("name"), |
| 158 | + NumericField.of("$.age").as("age")); |
| 159 | + |
| 160 | +SearchResult result = jedis.ftSearch("idx:users", "@name:John"); |
| 161 | +``` |
| 162 | + |
| 163 | +### SslOptions for Advanced SSL Configuration |
| 164 | + |
| 165 | +A new `SslOptions` class provides advanced SSL/TLS configuration options for secure connections. |
| 166 | + |
| 167 | +**Features:** |
| 168 | +- Custom keystore and truststore configuration |
| 169 | +- SSL protocol selection |
| 170 | +- SSL verification mode control |
| 171 | +- SSL parameters customization |
| 172 | + |
| 173 | +**Example:** |
| 174 | +```java |
| 175 | +SslOptions sslOptions = SslOptions.builder() |
| 176 | + .keystore(new File("/path/to/keystore.jks")) |
| 177 | + .keystorePassword("keystorePassword".toCharArray()) |
| 178 | + .truststore(new File("/path/to/truststore.jks")) |
| 179 | + .truststorePassword("truststorePassword".toCharArray()) |
| 180 | + .sslVerifyMode(SslVerifyMode.FULL) |
| 181 | + .build(); |
| 182 | + |
| 183 | +JedisClientConfig config = DefaultJedisClientConfig.builder() |
| 184 | + .ssl(true) |
| 185 | + .sslOptions(sslOptions) |
| 186 | + .build(); |
| 187 | + |
| 188 | +JedisPooled jedis = new JedisPooled("localhost", 6379, config); |
| 189 | +``` |
| 190 | + |
| 191 | +### Token-Based Authentication |
| 192 | + |
| 193 | +Jedis 6.0.0 introduces support for token-based authentication, useful for cloud environments and managed Redis services. |
| 194 | + |
| 195 | +**Example:** |
| 196 | +```java |
| 197 | +// Token-based authentication with automatic token refresh |
| 198 | +TokenCredentials tokenCredentials = new TokenCredentials("initial-token"); |
| 199 | + |
| 200 | +JedisClientConfig config = DefaultJedisClientConfig.builder() |
| 201 | + .credentials(tokenCredentials) |
| 202 | + .build(); |
| 203 | + |
| 204 | +JedisPooled jedis = new JedisPooled("localhost", 6379, config); |
| 205 | + |
| 206 | +// Token can be updated dynamically |
| 207 | +tokenCredentials.updateToken("new-token"); |
| 208 | +``` |
| 209 | + |
| 210 | +### New Hash Commands |
| 211 | + |
| 212 | +Support for new hash field expiration commands introduced in Redis 7.4: |
| 213 | + |
| 214 | +- `HGETDEL` - Get and delete a hash field |
| 215 | +- `HGETEX` - Get a hash field with expiration options |
| 216 | +- `HSETEX` - Set a hash field with expiration |
| 217 | + |
| 218 | +**Example:** |
| 219 | +```java |
| 220 | +// HSETEX - Set field with expiration |
| 221 | +jedis.hsetex("user:1", 3600, "session", "abc123"); |
| 222 | + |
| 223 | +// HGETEX - Get field and update expiration |
| 224 | +String session = jedis.hgetex("user:1", "session", |
| 225 | + HGetExParams.hgetExParams().ex(7200)); |
| 226 | + |
| 227 | +// HGETDEL - Get and delete field |
| 228 | +String oldSession = jedis.hgetdel("user:1", "session"); |
| 229 | +``` |
| 230 | + |
| 231 | +### Search Warning Messages |
| 232 | + |
| 233 | +Search and aggregation queries now support warning messages in results, helping identify potential issues with queries. |
| 234 | + |
| 235 | +**Example:** |
| 236 | +```java |
| 237 | +SearchResult result = jedis.ftSearch("idx:products", "@name:laptop"); |
| 238 | + |
| 239 | +// Check for warnings |
| 240 | +if (result.hasWarnings()) { |
| 241 | + List<String> warnings = result.getWarnings(); |
| 242 | + warnings.forEach(warning -> |
| 243 | + System.out.println("Search warning: " + warning)); |
| 244 | +} |
| 245 | +``` |
| 246 | + |
| 247 | +## Additional Resources |
| 248 | + |
| 249 | +- [Redis 8.0 Release Notes](https://github.com/redis/redis/blob/8.0/00-RELEASENOTES) |
| 250 | +- [Redis Search Documentation](https://redis.io/docs/interact/search-and-query/) |
| 251 | +- [Redis Query Dialects](https://redis.io/docs/interact/search-and-query/advanced-concepts/dialects/) |
| 252 | + |
| 253 | +## Getting Help |
| 254 | + |
| 255 | +If you encounter issues during migration: |
| 256 | + |
| 257 | +1. Check the [Jedis GitHub Issues](https://github.com/redis/jedis/issues) |
| 258 | +2. Join the [Redis Discord](https://discord.gg/redis) |
| 259 | +3. Review the [Jedis Javadocs](https://www.javadoc.io/doc/redis.clients/jedis/latest/) |
| 260 | +4. Start a [Discussion](https://github.com/redis/jedis/discussions) |
| 261 | + |
0 commit comments