Skip to main content
Use GETDEL to read the value of a key and delete the key in the same atomic step. The reply is the value, or null when the key does not exist, and an error when the value is not a string. Because nothing can run between the read and the delete, exactly one caller can obtain the value, which is what makes it right for one-shot data such as a one-time token, a password reset code, or a handoff between two processes. It replaces the GET plus DEL pair and its race.

Syntax

Arguments

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 TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

GETDELGETOverview