{"record":{"id":"3e16bf287ce5e1c7","repo":"redis/redis-py","slug":"to-maximize-compatibility-with-all-redis-products","errorCode":null,"errorMessage":"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later","messagePattern":"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7\\.4 or later","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"redis/connection.py","lineNumber":1743,"sourceCode":"        self._conn.connect()\n\n        server_name = self._conn.handshake_metadata.get(b\"server\", None)\n        if server_name is None:\n            server_name = self._conn.handshake_metadata.get(\"server\", None)\n        server_ver = self._conn.handshake_metadata.get(b\"version\", None)\n        if server_ver is None:\n            server_ver = self._conn.handshake_metadata.get(\"version\", None)\n        if server_ver is None or server_name is None:\n            raise ConnectionError(\"Cannot retrieve information about server version\")\n\n        server_ver = ensure_string(server_ver)\n        server_name = ensure_string(server_name)\n\n        if (\n            server_name != self.DEFAULT_SERVER_NAME\n            or compare_versions(server_ver, self.MIN_ALLOWED_VERSION) == 1\n        ):\n            raise ConnectionError(\n                \"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later\"  # noqa: E501\n            )\n\n    def on_connect(self):\n        self._conn.on_connect()\n\n    def disconnect(self, *args, **kwargs):\n        with self._cache_lock:\n            self._cache.flush()\n        self._conn.disconnect(*args, **kwargs)\n\n    def check_health(self):\n        self._conn.check_health()\n\n    def send_packed_command(self, command, check_health=True):\n        # TODO: Investigate if it's possible to unpack command\n        #  or extract keys from packed command\n        # Pre-packed commands are not individually cacheable, so make sure the","sourceCodeStart":1725,"sourceCodeEnd":1761,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/connection.py#L1725-L1761","documentation":"Raised in CacheProxyConnection.connect (connection.py:1739-1745) after the server identity is retrieved, when the server name is not 'redis' OR the version is older than MIN_ALLOWED_VERSION ('7.4.0'). Client-side caching via the cache proxy is only supported on genuine Redis >= 7.4 to maximise compatibility across products; anything else (Valkey, older Redis, or Redis < 7.4) is rejected at connect time.","triggerScenarios":"Enabling the client-side cache against Valkey, Redis < 7.4, or any server whose HELLO 'server' field is not 'redis'. compare_versions(server_ver,'7.4.0')==1 means the detected version is strictly less than 7.4.0.","commonSituations":"Dev environment on an older Redis; using Valkey as a Redis replacement; assuming the cache works on any RESP3 server.","solutions":["Upgrade to Redis >= 7.4.0 if you need client-side caching.","Disable the cache (remove cache=) on incompatible servers.","If on Valkey/other, do not enable this client-side caching feature.","Verify with INFO server / HELLO that server name is 'redis' and version >= 7.4."],"exampleFix":"# before\nr = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)  # Redis 7.2\n# after\nr = redis.Redis(host=h, port=p, protocol=3)  # no cache on <7.4","handlingStrategy":"validation","validationCode":"from redis.connection import CacheProxyConnection\nMIN = CacheProxyConnection.MIN_ALLOWED_VERSION  # '7.4.0'\n\ninfo = redis.Redis(host=h, port=p, protocol=3).info('server')\nok = info.get('redis_version') and compare_versions(info['redis_version'], MIN) <= 0\nr = redis.Redis(host=h, port=p, protocol=3, cache=my_cache) if ok else \\\n    redis.Redis(host=h, port=p, protocol=3)  # no cache on older/non-redis","typeGuard":"def supports_csc(info: dict) -> bool:\n    return (\n        info.get('redis_version', '0.0.0') is not None\n        and compare_versions(info['redis_version'], '7.4.0') <= 0\n    )","tryCatchPattern":"from redis.exceptions import ConnectionError\ntry:\n    r = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)\n    r.ping()\nexcept ConnectionError as e:\n    if 'client-side caching' in str(e):\n        r = redis.Redis(host=h, port=p, protocol=3)  # disable cache\n    else:\n        raise","preventionTips":["Gate client-side caching on INFO server: name=='redis' and version>=7.4.","Don't enable the cache on Valkey or Redis < 7.4.","Keep a no-cache fallback config for lower environments."],"tags":["client-side-caching","redis-version","compatibility","configuration"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}