DIGEST to get the digest of a string value.
The reply is a 16-character lowercase hexadecimal XXH3 digest of the stored bytes, null when the key does not exist, and an error when the value is not a string. It is a fast non-cryptographic hash, meant for change detection rather than for security.
Comparing digests lets a client tell whether a large value has changed without transferring it, for instance to decide whether a cached copy is still current. The same digest can be passed to the conditional forms of SET (IFDEQ, IFDNE) and DELEX, which turns it into a compact compare-and-set token for large values. DIGEST is an Upstash extension.
Syntax
Arguments
Important points
- The reply is a 16-character lowercase hexadecimal XXH3 digest of the stored string bytes.
- A missing key returns null. A key containing a non-string value returns
WRONGTYPE.
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
This command is not supported yet in
@upstash/redis.upstash_redis
upstash_redis
This command is not supported yet in
upstash_redis.ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs