UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'w12n347NnbDJpP9gwRMqgNXs2ogo2za9iBW2jcYCaX4='
WHERE
key_id = 'e2aedb24c0d8985840487554c8aaf90c08b126e96c0fd2f7c8983f3abffe6bd8'
AND (
token = 'w12n347NnbDJpP9gwRMqgNXs2ogo2za9iBW2jcYCaX4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)