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