Back to Redis

DIGEST

content/commands/digest.md

latest2.1 KB
Original Source

Get the hash digest for the value stored in the specified key as a hexadecimal string. Keys must be of type string.

Hash Digest

A hash digest is a fixed-size numerical representation of a string value, computed using the XXH3 hash algorithm. Redis uses this hash digest for efficient comparison operations without needing to compare the full string content. You can use these hash digests with the [SET]({{< relref "/commands/set" >}}) command's IFDEQ and IFDNE options, and also the [DELEX]({{< relref "/commands/delex" >}}) command's IFDEQ and IFDNE options.

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | |

Example

bash
> SET key1 "Hello world"
OK
> DIGEST key1
"b6acb9d84a38ff74"

Return information

{{< multitabs id="return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • [Null bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) if the key does not exist.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value which is not a string.
  • [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) the hash digest of the value stored in the key as a hexadecimal string.

-tab-sep-

One of the following:

  • [Null bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) if the key does not exist.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value which is not a string.
  • [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) the hash digest of the value stored in the key as a hexadecimal string.

{{< /multitabs >}}