{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/cluster.py#L869-L905","documentation":"Raised in `RedisCluster.__init__` when `cache_config` or `cache` is supplied but the negotiated protocol is not RESP3. Client-side caching (the tracking + invalidation mechanism) requires Redis RESP3 push notifications, so enabling a cache with protocol < 3 is rejected with RedisError rather than silently degrading.","triggerScenarios":"Constructing `RedisCluster(cache_config=CacheConfig(...), protocol=2)` or omitting protocol (which must then default to 3) while requesting a cache. The check `not check_protocol_version(protocol, 3)` triggers when RESP3 is not in effect.","commonSituations":"Forcing `protocol=2` for compatibility with an older server while still trying to use client caching; supplying a default `CacheConfig` without also setting `protocol=3`; talking to a Redis < 6 (no RESP3) and enabling caching.","solutions":["Set `protocol=3` (and ensure the server is Redis >= 6 with RESP3 support) when using client caching.","If the server cannot do RESP3, remove `cache_config`/`cache` from the constructor.","Upgrade the Redis server to a version that supports RESP3 if you need client-side caching."],"exampleFix":"# before\nrc = RedisCluster(host='h', port=7000, protocol=2, cache_config=CacheConfig())  # raises\n\n# after\nrc = RedisCluster(host='h', port=7000, protocol=3, cache_config=CacheConfig())","handlingStrategy":"validation","validationCode":"protocol = kwargs.get('protocol', 3)\nif (cache_config or cache) and protocol != 3:\n    raise ValueError('Client-side caching requires RESP3 (protocol=3)')","typeGuard":"def cache_protocol_compatible(protocol, cache_config, cache) -> bool:\n    return (cache_config is None and cache is None) or protocol == 3","tryCatchPattern":null,"preventionTips":["Set protocol=3 whenever enabling cache_config/cache.","Ensure the Redis server is >= 6 and supports RESP3.","Do not force protocol=2 together with client-side caching."],"tags":["cluster","client-side-caching","resp3","config"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}