calculate_value_digest in redis - Rust
Description: Calculates a digest/hash of the given value for use with Redis value comparison operations. This function uses the XXH3 algorithm, which is the same algorithm used by Redis for its DIGEST command. The resulting digest can be used with `ValueComparison::IFDEQ` and `ValueComparison::IFDNE`.

Skip to main content

## calculate_value_digest

# Function calculate_value_digest

Source

    pub fn calculate_value_digest<T: ToRedisArgs>(value: T) -> String

Expand description

Calculates a digest/hash of the given value for use with Redis value comparison operations. This function uses the XXH3 algorithm, which is the same algorithm used by Redis for its DIGEST command. The resulting digest can be used with `ValueComparison::IFDEQ` and `ValueComparison::IFDNE`.

## §Example

    use redis::{calculate_value_digest, ValueComparison, SetOptions};

    let value = "my_value";
    let digest = calculate_value_digest(value);

    // Use the digest in a value comparison
    let opts = SetOptions::default()
        .value_comparison(ValueComparison::ifdeq(&digest));