HGETDEL command returns the values of the specified fields and then atomically deletes them from the hash. This is useful when you need to retrieve and remove data in a single atomic operation.
Arguments
string
required
The key of the hash.
...string[]
required
One or more field names to get and delete.
Response
An object containing the field names and their values in the format
{[fieldName: string]: TValue | null}. Returns null for fields that do not exist. If the hash doesn’t exist or all fields are non-existent, null is returned.Use Cases
- Session Management: Retrieve and invalidate session data atomically
- Cache Cleanup: Get cached data while removing it from storage
- Queue Processing: Fetch and remove job data in a single operation
- Temporary Data: Retrieve one-time use tokens or codes while deleting them