UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'gqSd9vfilssowARr2oxYvIoJXaSv1j7PMXyyZKe/M1w='
WHERE
key_id = 'afdb142293d9961beb083bf2117215afe04d3227aa753dae54d2225ce0ae93e8'
AND (
token = 'gqSd9vfilssowARr2oxYvIoJXaSv1j7PMXyyZKe/M1w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)