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