|
| 1 | +# Valkey GLIDE Compatibility Layer Migration Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The Valkey GLIDE compatibility layer enables seamless migration from Jedis to Valkey GLIDE with minimal code changes. This guide covers supported features, migration steps, and current limitations. |
| 6 | + |
| 7 | +## Quick Migration |
| 8 | + |
| 9 | +### Step 1: Update Dependencies |
| 10 | + |
| 11 | +Replace your Jedis dependency with Valkey GLIDE: |
| 12 | + |
| 13 | +**Before (Jedis):** |
| 14 | +```gradle |
| 15 | +dependencies { |
| 16 | + implementation 'redis.clients:jedis:5.1.5' |
| 17 | +} |
| 18 | +``` |
| 19 | + |
| 20 | +**After (Valkey GLIDE):** |
| 21 | +```gradle |
| 22 | +dependencies { |
| 23 | + implementation group: 'io.valkey', name: 'valkey-glide', version: '1.+', classifier: 'osx-aarch_64' |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +### Step 2: No Code Changes Required |
| 28 | + |
| 29 | +Your existing Jedis code works without modification: |
| 30 | + |
| 31 | +```java |
| 32 | +import redis.clients.jedis.Jedis; |
| 33 | + |
| 34 | +public class JedisExample { |
| 35 | + public static void main(String[] args) { |
| 36 | + Jedis jedis = new Jedis(); |
| 37 | + |
| 38 | + // Basic operations work unchanged |
| 39 | + String setResult = jedis.set("user:1001:name", "John Doe"); |
| 40 | + String getValue = jedis.get("user:1001:name"); |
| 41 | + } |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +### How to switch without a recompile? |
| 46 | +Change the application's classpath such that it does not have the Jedis JAR and instead has Glide + the Jedis compatibility layer. |
| 47 | + |
| 48 | +## Supported input parameters |
| 49 | + |
| 50 | +### Configuration Mapping Overview |
| 51 | + |
| 52 | +The compatibility layer provides varying levels of support for Jedis configuration parameters, based on detailed analysis of `DefaultJedisClientConfig` fields: |
| 53 | + |
| 54 | +#### ✅ Successfully Mapped |
| 55 | +- `user` → `ServerCredentials.username` |
| 56 | +- `password` → `ServerCredentials.password` |
| 57 | +- `clientName` → `BaseClientConfiguration.clientName` |
| 58 | +- `ssl` → `BaseClientConfiguration.useTLS` |
| 59 | +- `redisProtocol` → `BaseClientConfiguration.protocol` |
| 60 | +- `connectionTimeoutMillis` → `AdvancedBaseClientConfiguration.connectionTimeout` |
| 61 | +- `socketTimeoutMillis` → `BaseClientConfiguration.requestTimeout` |
| 62 | +- `database` → Handled via SELECT command after connection |
| 63 | + |
| 64 | +#### 🔶 Partially Mapped |
| 65 | +- `sslSocketFactory` → Requires SSL/TLS migration to system certificate store |
| 66 | +- `sslParameters` → Limited mapping; custom protocols/ciphers not supported |
| 67 | +- `hostnameVerifier` → Standard verification works; custom verifiers require `useInsecureTLS` |
| 68 | + |
| 69 | +#### ❌ Not Mapped |
| 70 | +- `blockingSocketTimeoutMillis` → No equivalent (GLIDE uses async I/O model) |
| 71 | + |
| 72 | +### SSL/TLS Configuration Complexity |
| 73 | + |
| 74 | +#### Internal SSL Fields Analysis (21 sub-fields total): |
| 75 | +- **SSLParameters**: 3/9 fields partially mapped |
| 76 | +- **SSLSocketFactory**: 1/8 fields directly mapped |
| 77 | +- **HostnameVerifier**: 2/4 verification types mapped |
| 78 | + |
| 79 | +#### Migration Requirements by Complexity: |
| 80 | + |
| 81 | +**Low Complexity** |
| 82 | +- Direct parameter mapping |
| 83 | +- No code changes required |
| 84 | +- Examples: Basic auth, timeouts, protocol selection |
| 85 | + |
| 86 | +**Medium Complexity** |
| 87 | +- SSL/TLS certificate migration required |
| 88 | +- System certificate store installation needed |
| 89 | +- Custom SSL configurations → GLIDE secure defaults |
| 90 | + |
| 91 | +**High Complexity** |
| 92 | +- No GLIDE equivalent |
| 93 | +- Architectural differences (async vs blocking I/O) |
| 94 | +- Requires application redesign |
| 95 | + |
| 96 | +### Overall Migration Success Rate |
| 97 | + |
| 98 | +**Including SSL/TLS Internal Fields:** |
| 99 | +- **Total analyzable fields**: 33 (12 main + 21 SSL internal) |
| 100 | +- **Successfully mapped**: 9/33 |
| 101 | +- **Partially mapped with migration**: 11/33 |
| 102 | +- **Not mappable**: 13/33 |
| 103 | + |
| 104 | +### Key Migration Insights |
| 105 | + |
| 106 | +1. **GLIDE Architecture Shift**: From application-managed SSL to system-managed SSL with secure defaults |
| 107 | +2. **Certificate Management**: Custom keystores/truststores require migration to system certificate store |
| 108 | +3. **Protocol Selection**: GLIDE auto-selects TLS 1.2+ and secure cipher suites |
| 109 | +4. **Client Authentication**: Client certificates not supported; use username/password authentication |
| 110 | + |
| 111 | +## Supported Features |
| 112 | + |
| 113 | +### Core Commands |
| 114 | +- ✅ Basic string operations (GET, SET, MGET, MSET) |
| 115 | +- ✅ Hash operations (HGET, HSET, HMGET, HMSET) |
| 116 | +- ✅ List operations (LPUSH, RPUSH, LPOP, RPOP) |
| 117 | +- ⚠️ Set operations (SADD, SREM, SMEMBERS) - **Available via `sendCommand()` only** |
| 118 | +- ⚠️ Sorted set operations (ZADD, ZREM, ZRANGE) - **Available via `sendCommand()` only** |
| 119 | +- ✅ Key operations (DEL, EXISTS, EXPIRE, TTL) |
| 120 | +- ✅ Connection commands (PING, SELECT) |
| 121 | +- ✅ Generic commands via `sendCommand()` (Protocol.Command types only) |
| 122 | + |
| 123 | +### Client Types |
| 124 | +- ✅ Basic Jedis client |
| 125 | +- ✅ Simple connection configurations |
| 126 | +- ⚠️ JedisPool (limited support) |
| 127 | +- ⚠️ JedisPooled (limited support) |
| 128 | + |
| 129 | +### Configuration |
| 130 | +- ✅ Host and port configuration |
| 131 | +- ✅ Basic authentication |
| 132 | +- ✅ Database selection |
| 133 | +- ✅ Connection timeout |
| 134 | +- ⚠️ SSL/TLS (partial support) |
| 135 | + |
| 136 | +## Drawbacks and Unsupported Features |
| 137 | + |
| 138 | +### Connection Management |
| 139 | +- ❌ **JedisPool advanced configurations**: Complex pool settings not fully supported |
| 140 | +- ❌ **JedisPooled**: Advanced pooled connection features unavailable |
| 141 | +- ❌ **Connection pooling**: Native Jedis pooling mechanisms not implemented |
| 142 | +- ❌ **Failover configurations**: Jedis-specific failover logic not supported |
| 143 | + |
| 144 | +### Advanced Features |
| 145 | +- ❌ **Transactions**: MULTI/EXEC transaction blocks not supported |
| 146 | +- ❌ **Pipelining**: Jedis pipelining functionality unavailable |
| 147 | +- ❌ **Pub/Sub**: Redis publish/subscribe not implemented |
| 148 | +- ❌ **Lua scripting**: EVAL/EVALSHA commands not supported |
| 149 | +- ❌ **Modules**: Redis module commands not available |
| 150 | +- ⚠️ **Typed set/sorted set methods**: No dedicated methods like `sadd()`, `zadd()` - use `sendCommand()` instead |
| 151 | + |
| 152 | +### Configuration Limitations |
| 153 | +- ❌ **Complex SSL configurations**: Jedis `JedisClientConfig` SSL parameters cannot be mapped to Valkey GLIDE `GlideClientConfiguration` |
| 154 | +- ❌ **Custom trust stores**: SSL trust store configurations require manual migration |
| 155 | +- ❌ **Client certificates**: SSL client certificate authentication not supported in compatibility layer |
| 156 | +- ❌ **SSL protocols and cipher suites**: Advanced SSL protocol settings cannot be automatically converted |
| 157 | +- ❌ **Custom serializers**: Jedis serialization options not supported |
| 158 | +- ❌ **Connection validation**: Jedis connection health checks unavailable |
| 159 | +- ❌ **Retry mechanisms**: Jedis-specific retry logic not implemented |
| 160 | + |
| 161 | +### Cluster Support |
| 162 | +- ❌ **JedisCluster**: Cluster client not supported in compatibility layer |
| 163 | +- ❌ **Cluster failover**: Automatic cluster failover not available |
| 164 | +- ❌ **Hash slot management**: Manual slot management not supported |
| 165 | + |
| 166 | +### Performance Features |
| 167 | +- ❌ **Async operations**: Jedis async methods not implemented |
| 168 | +- ❌ **Batch operations**: Bulk operation optimizations unavailable |
| 169 | +- ❌ **Custom protocols**: Protocol customization not supported |
| 170 | + |
| 171 | +## Migration Considerations |
| 172 | + |
| 173 | +### Before Migration |
| 174 | +1. **Audit your codebase** for unsupported features listed above |
| 175 | +2. **Test thoroughly** in a development environment |
| 176 | +3. **Review connection configurations** for compatibility |
| 177 | +4. **Plan for feature gaps** that may require code changes |
| 178 | + |
| 179 | +### Recommended Approach |
| 180 | +1. Start with simple applications using basic commands |
| 181 | +2. Gradually migrate complex features to native Valkey GLIDE APIs |
| 182 | +3. Consider hybrid approach for applications with unsupported features |
| 183 | +4. Monitor performance and behavior differences |
| 184 | + |
| 185 | +### Alternative Migration Path |
| 186 | +For applications heavily using unsupported features, consider migrating directly to native Valkey GLIDE APIs: |
| 187 | + |
| 188 | +```java |
| 189 | +import glide.api.GlideClient; |
| 190 | +import glide.api.models.configuration.GlideClientConfiguration; |
| 191 | +import glide.api.models.configuration.NodeAddress; |
| 192 | + |
| 193 | +GlideClientConfiguration config = GlideClientConfiguration.builder() |
| 194 | + .address(NodeAddress.builder().host("localhost").port(6379).build()) |
| 195 | + .build(); |
| 196 | + |
| 197 | +try (GlideClient client = GlideClient.createClient(config).get()) { |
| 198 | + client.set(gs("key"), gs("value")).get(); |
| 199 | +} |
| 200 | +``` |
| 201 | + |
| 202 | +## Getting Help |
| 203 | + |
| 204 | +- Review the [main README](https://github.com/valkey-io/valkey-glide/blob/main/README.md) for native Valkey GLIDE usage |
| 205 | +- Check [integration tests](./integTest/src/test/java/glide) for examples |
| 206 | +- Report compatibility issues through the project's issue tracker |
| 207 | + |
| 208 | +## Known Challenges and Limitations |
| 209 | + |
| 210 | +### Version Compatibility Issues |
| 211 | +- ❌ **Jedis version incompatibility**: The compatibility layer targets latest Jedis versions, but many projects use older versions (e.g., 4.4.3) |
| 212 | +- ❌ **Backward compatibility**: Jedis itself is not backward compatible across major versions |
| 213 | +- ⚠️ **Multiple version support**: No clear strategy for supporting multiple Jedis versions simultaneously |
| 214 | + |
| 215 | +### Implementation Gaps |
| 216 | +- ⚠️ **Generic command support**: `sendCommand()` is implemented but only supports `Protocol.Command` types |
| 217 | +- ❌ **Stub implementations**: Many classes exist but lack full functionality, creating false expectations |
| 218 | +- ❌ **Runtime failures**: Build-time success doesn't guarantee runtime compatibility |
| 219 | + |
| 220 | +## Migration Warnings |
| 221 | + |
| 222 | +### Before You Start |
| 223 | +1. **Check your Jedis version**: Compatibility layer may not support older Jedis versions |
| 224 | +2. **Verify command types**: `sendCommand()` only supports `Protocol.Command` types, not custom `ProtocolCommand` implementations |
| 225 | +3. **Test thoroughly**: Classes may exist but lack implementation |
| 226 | +4. **Expect runtime failures**: Successful compilation doesn't guarantee runtime success |
| 227 | +5. **Review SSL/TLS configurations**: Advanced SSL settings require manual migration to native Valkey GLIDE APIs |
| 228 | + |
| 229 | +### Recommended Testing Strategy |
| 230 | +1. **Start with simple operations** to verify basic compatibility |
| 231 | +2. **Test all code paths** - don't rely on successful compilation |
| 232 | +3. **Monitor for runtime exceptions** from stub implementations |
| 233 | +4. **Have rollback plan** ready for incompatible features |
| 234 | + |
| 235 | +## Next Steps |
| 236 | + |
| 237 | +The compatibility layer is under active development. Priority improvements include: |
| 238 | +- Multi-version Jedis support strategy |
| 239 | +- Enhanced JedisPool support |
| 240 | +- Complete `sendCommand()` implementation |
| 241 | +- Runtime compatibility validation |
| 242 | +- Clear documentation of stub vs. implemented features |
0 commit comments