{"record":{"id":"6eeb15273765331b","repo":"redis/jedis","slug":"client-side-caching-is-only-supported-with-resp3","errorCode":null,"errorMessage":"Client-side caching is only supported with RESP3.","messagePattern":"Client-side caching is only supported with RESP3\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/UnifiedJedis.java","lineNumber":144,"sourceCode":"    // RESP2 or RESP3 on the wire. Probe a connection to learn the actual value so the command\n    // objects parse replies with the correct decoder. If the probe fails or the connection has\n    // not yet negotiated, fall back to RESP2 — matching the wire default and preserving lazy\n    // construction semantics.\n    RedisProtocol resolvedProtocol = protocol;\n    if (resolvedProtocol == null && provider != null) {\n      try (Connection conn = provider.getConnection()) {\n        if (conn != null) {\n          resolvedProtocol = conn.getRedisProtocol();\n        }\n      } catch (JedisException ignored) {\n      }\n    }\n    if (resolvedProtocol == null) {\n      resolvedProtocol = RedisProtocol.RESP2;\n    }\n\n    if (cache != null && resolvedProtocol != RedisProtocol.RESP3) {\n      throw new IllegalArgumentException(\"Client-side caching is only supported with RESP3.\");\n    }\n\n    this.commandObjects = newCommandObjects(resolvedProtocol);\n    applyCommandObjectsConfiguration(commandObjects, clientConfig);\n    this.cache = cache;\n  }\n\n  /**\n   * Factory hook for the {@link CommandObjects} instance held by this client. Subclasses (e.g.\n   * {@link JedisCluster}) override to return their specialized subtype. Called from the\n   * {@link UnifiedJedis} constructor — must not depend on subclass instance state.\n   */\n  protected CommandObjects newCommandObjects(RedisProtocol protocol) {\n    return new CommandObjects(protocol);\n  }\n\n  /**\n   * Applies the {@code CommandObjects}-level knobs ({@code commandKeyArgumentPreProcessor},","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/UnifiedJedis.java#L126-L162","documentation":"Client-side caching (RedisPROTOCOL-dependent server-assisted invalidation) requires RESP3, because it relies on push messages. Constructing a UnifiedJedis-derived client with both a Cache configured and RESP2 protocol throws IllegalArgumentException immediately.","triggerScenarios":"new RedisClient(...)/builder with .cache(...) while protocol is RESP2 or defaulted to RESP2; e.g. clientConfig.protocol(RedisProtocol.RESP2) plus a Cache instance.","commonSituations":"Upgrading an old RESP2-based config to add client-side caching; copying a cache example without setting RESP3; protocol defaulting to RESP2 in legacy config code paths.","solutions":["Set the protocol to RESP3 in the ClientConfig: clientConfig.protocol(RedisProtocol.RESP3).","Ensure the Redis server is v6+ and speaks RESP3.","If RESP2 is mandatory, remove the cache from the configuration."],"exampleFix":"// before\nClientConfig cfg = new ClientConfig().protocol(RedisProtocol.RESP2);\nRedisClient c = RedisClient.builder().clientConfig(cfg).cache(new CachedRedisClient.Cache()).build();\n// after\nClientConfig cfg = new ClientConfig().protocol(RedisProtocol.RESP3);\nRedisClient c = RedisClient.builder().clientConfig(cfg).cache(new Caches.cache()).build();","handlingStrategy":"validation","validationCode":"if (cache != null && (protocol == null || protocol == RedisProtocol.RESP2)) {\n  throw new IllegalArgumentException(\"cache requires RESP3\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  RedisClient c = RedisClient.builder().clientConfig(cfg).cache(cache).build();\n} catch (IllegalArgumentException e) {\n  log.error(\"CSC requires RESP3: {}\", e.getMessage());\n}","preventionTips":["Always set protocol(RESP3) when enabling client-side caching","Verify server supports RESP3 (Redis 6+)","Don't pass a Cache with legacy RESP2 configs"],"tags":["client-side-caching","resp3","configuration","jedis"],"backgroundTag":"unsupported-config-value","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}