{"record":{"id":"9759ac8db246591d","repo":"redis/redis-py","slug":"client-caching-is-only-supported-with-resp-version-9759ac","errorCode":null,"errorMessage":"Client caching is only supported with RESP version 3","messagePattern":"Client caching is only supported with RESP version 3","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":887,"sourceCode":"        kwargs = cleanup_kwargs(**kwargs)\n        if retry:\n            self.retry = retry\n        else:\n            self.retry = Retry(\n                backoff=ExponentialWithJitterBackoff(\n                    base=DEFAULT_RETRY_BASE, cap=DEFAULT_RETRY_CAP\n                ),\n                retries=cluster_error_retry_attempts,\n            )\n\n        self.encoder = Encoder(\n            kwargs.get(\"encoding\", \"utf-8\"),\n            kwargs.get(\"encoding_errors\", \"strict\"),\n            kwargs.get(\"decode_responses\", False),\n        )\n        protocol = kwargs.get(\"protocol\", None)\n        if (cache_config or cache) and not check_protocol_version(protocol, 3):\n            raise RedisError(\"Client caching is only supported with RESP version 3\")\n\n        if (\n            maint_notifications_config\n            and maint_notifications_config.enabled\n            and not check_protocol_version(protocol, 3)\n        ):\n            raise RedisError(\n                \"Maintenance notifications are only supported with RESP version 3\"\n            )\n        if check_protocol_version(protocol, 3) and maint_notifications_config is None:\n            maint_notifications_config = MaintNotificationsConfig()\n\n        # Build the client-level HIMPORT registry once (always empty at construction)\n        # and share the same object with every node pool, so the fieldset registry is\n        # shared cluster-wide and runtime himport_prepare mutates one object. It is\n        # handed to the NodesManager and injected onto each node's pool in\n        # create_redis_node; it is deliberately NOT forwarded through connection_kwargs,\n        # so nodes reuse the one shared object rather than each rebuilding their own.","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L869-L905","documentation":"Raised by RedisCluster.__init__ when client-side caching (cache_config or cache) is enabled but the negotiated RESP protocol version is not 3. Server-assisted client-side caching (push messages, cache invalidation) requires the RESP3 protocol, so the constructor rejects the combination eagerly at cluster.py:886.","triggerScenarios":"RedisCluster(host=..., cache_config=CacheConfig(...)) or RedisCluster(host=..., cache=Cache(...)) without setting protocol=3 (or with protocol=2 / default-less config that resolves to RESP2).","commonSituations":"Enabling the cache without upgrading the wire protocol; sharing config between standalone (protocol may default differently) and cluster clients; assuming the default protocol is RESP3 when it resolves to RESP2 in your environment.","solutions":["Set protocol=3 when enabling caching: RedisCluster(host=..., protocol=3, cache_config=...).","Verify no global default forces protocol=2 in your config.","Drop cache_config/cache if you cannot use RESP3 in your deployment."],"exampleFix":"// before\nclient = RedisCluster(host='localhost', port=7000, cache_config=CacheConfig())  # RedisError\n\n// after\nclient = RedisCluster(host='localhost', port=7000, protocol=3, cache_config=CacheConfig())","handlingStrategy":"validation","validationCode":"from redis._parsers.helpers import check_protocol_version\nprotocol = kwargs.get('protocol')\nif (cache_config or cache) and not check_protocol_version(protocol, 3):\n    kwargs['protocol'] = 3  # or drop cache_config\nclient = RedisCluster(host='localhost', port=7000, protocol=kwargs.get('protocol', 3), cache_config=cache_config)","typeGuard":"def cache_config_is_resp3_compatible(kwargs, cache_config, cache) -> bool:\n    from redis._parsers.helpers import check_protocol_version\n    return not (cache_config or cache) or check_protocol_version(kwargs.get('protocol'), 3)","tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    client = RedisCluster(host='localhost', port=7000, cache_config=cache_config)\nexcept RedisError as e:\n    if 'RESP version 3' in str(e):\n        client = RedisCluster(host='localhost', port=7000, protocol=3, cache_config=cache_config)\n    else:\n        raise","preventionTips":["Set protocol=3 whenever you enable client-side caching.","Do not let global defaults force protocol=2 when caching is on.","Drop cache_config if your deployment cannot use RESP3."],"tags":["cluster","config","resp3","client-side-caching"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}