{"record":{"id":"6c1e728f31adca6d","repo":"redis/redis-py","slug":"client-caching-is-only-supported-with-resp-version","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/client.py","lineNumber":527,"sourceCode":"                AfterPooledConnectionsInstantiationEvent(\n                    [connection_pool], ClientType.SYNC, credential_provider\n                )\n            )\n            self.auto_close_connection_pool = True\n        else:\n            self.auto_close_connection_pool = False\n            self._event_dispatcher.dispatch(\n                AfterPooledConnectionsInstantiationEvent(\n                    [connection_pool], ClientType.SYNC, credential_provider\n                )\n            )\n\n        self.connection_pool = connection_pool\n\n        if (cache_config or cache) and not check_protocol_version(\n            self.connection_pool.get_protocol(), 3\n        ):\n            raise RedisError(\"Client caching is only supported with RESP version 3\")\n\n        self.single_connection_lock = threading.RLock()\n        self.connection = None\n        self._single_connection_client = single_connection_client\n        if self._single_connection_client:\n            self.connection = self.connection_pool.get_connection()\n            self._event_dispatcher.dispatch(\n                AfterSingleConnectionInstantiationEvent(\n                    self.connection, ClientType.SYNC, self.single_connection_lock\n                )\n            )\n\n        connection_kwargs = self.connection_pool.connection_kwargs\n        self.response_callbacks = CaseInsensitiveDict(\n            get_response_callbacks(\n                user_protocol=connection_kwargs.get(\"protocol\"),\n                legacy_responses=connection_kwargs.get(\"legacy_responses\", True),\n            )","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/client.py#L509-L545","documentation":"Raised as RedisError during Redis.__init__ when client-side caching (cache_config or cache) is provided but the connection pool protocol is not RESP3. Client-side caching depends on RESP3 push notifications (invalidation messages), so it cannot function under RESP2. The check at client.py:524-527 runs after the pool is created, reading the pool's resolved protocol.","triggerScenarios":"Constructing Redis(cache_config=CacheConfig(), protocol=2) or with the default resolving to non-3. The check fires after the connection pool is built and its protocol queried.","commonSituations":"Enabling CSC while pinned to RESP2 for legacy response shapes. Passing cache_config without also setting protocol=3. Migrating to CSC on a server/client config that defaults to RESP2.","solutions":["Set protocol=3 when configuring client-side caching.","Drop cache_config/cache if you must remain on RESP2.","Ensure the Redis server is 6+ and supports RESP3 invalidation."],"exampleFix":"# before\nr = Redis(cache_config=CacheConfig(), protocol=2)  # RedisError\n# after\nr = Redis(cache_config=CacheConfig(), protocol=3)","handlingStrategy":"validation","validationCode":"if (cache_config or cache) and protocol not in (3, \"3\"):\n    raise ValueError(\"client-side caching requires protocol=3\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set protocol=3 when enabling client-side caching.","Keep RESP3 capability checks in one config helper."],"tags":["configuration","client-side-caching","resp3","protocol"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}