{"record":{"id":"54b4454ffc970205","repo":"redis/redis-py","slug":"xxhash-support-requires-the-optional-xxhash-libr","errorCode":null,"errorMessage":"XXHASH support requires the optional 'xxhash' library. Install it with 'pip install xxhash' or use this package's extra with 'pip install redis[xxhash]' to enable this feature.","messagePattern":"XXHASH support requires the optional 'xxhash' library\\. Install it with 'pip install xxhash' or use this package's extra with 'pip install redis\\[xxhash\\]' to enable this feature\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":3137,"sourceCode":"        This is useful for conditional operations like IFDEQ/IFDNE where you need to\n        compute the digest client-side before sending a command.\n\n        Warning:\n        **Experimental** - This API may change or be removed without notice.\n\n        Arguments:\n          - value: Union[bytes, str] - the value to compute the digest of.\n            If a string is provided, it will be encoded using UTF-8 before hashing,\n            which matches Redis's default encoding behavior.\n\n        Returns:\n          - (str | bytes) the XXH3 digest of the value as a hex string (16 hex characters).\n            Returns bytes if decode_responses is False, otherwise returns str.\n\n        For more information, see https://redis.io/commands/digest\n        \"\"\"\n        if not HAS_XXHASH:\n            raise NotImplementedError(\n                \"XXHASH support requires the optional 'xxhash' library. \"\n                \"Install it with 'pip install xxhash' or use this package's extra with \"\n                \"'pip install redis[xxhash]' to enable this feature.\"\n            )\n\n        local_digest = xxhash.xxh3_64(value).hexdigest()\n\n        # To align with digest, we want to return bytes if decode_responses is False.\n        # The following works because of Python's mixin-based client class hierarchy.\n        if not self.get_encoder().decode_responses:\n            local_digest = local_digest.encode()\n\n        return local_digest\n\n    @overload\n    def digest(self: SyncClientProtocol, name: KeyT) -> str | bytes | None: ...\n\n    @overload","sourceCodeStart":3119,"sourceCodeEnd":3155,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L3119-L3155","documentation":"Raised as `NotImplementedError` by `digest_local()` (redis/commands/core.py:3136) when `HAS_XXHASH` is False, i.e. the optional `xxhash` package is not installed. The method computes an XXH3 hex digest client-side (for IFDEQ/IFDNE conditionals) and the C extension is required for that.","triggerScenarios":"Calling `r.digest_local(value)` in an environment where `xxhash` is not installed (the `redis[xxhash]` extra was not pulled in).","commonSituations":"Fresh checkout without installing extras; slim Docker images that `pip install redis` without extras; CI matrices that don't include the xxhash extra; upgrading redis-py and starting to use the new experimental digest API.","solutions":["Install the extra: `pip install redis[xxhash]` (or directly `pip install xxhash`).","Pin `xxhash` in your requirements if you use `digest_local`, `ifdeq`, or `ifdne` flows.","If you cannot add the dependency, use server-side `digest()` (DIGEST command) or plain `ifeq`/`ifne` instead."],"exampleFix":"// before: NotImplementedError at runtime\nval = r.digest_local(b'x')\n// after (shell)\n// pip install redis[xxhash]\n// then\nval = r.digest_local(b'x')","handlingStrategy":"try-catch","validationCode":"try:\n    import xxhash  # noqa: F401\n    HAS_XXHASH = True\nexcept ImportError:\n    HAS_XXHASH = False\nif not HAS_XXHASH:\n    raise RuntimeError('xxhash not installed; pip install redis[xxhash]')\nr.digest_local(b'x')","typeGuard":null,"tryCatchPattern":"try:\n    digest = r.digest_local(value)\nexcept NotImplementedError:\n    # fall back to server-side DIGEST or plain ifeq/ifne\n    digest = r.digest(name)","preventionTips":["Pin `redis[xxhash]` in requirements if you use digest_local/ifdeq/ifdne.","Detect optional deps at startup, not at first use."],"tags":["dependency","xxhash","digest","notimplementederror","optional-extra"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}