UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'BvYjjUxmuHuNTaHn2Vod7g8gLW6aZqJRFjke5tol7Uw='
WHERE
key_id = '5237f23b33dab9b6b5d6d3364b91b534f0d4f65c88329d7059eba98ff847a616'
AND (
token = 'BvYjjUxmuHuNTaHn2Vod7g8gLW6aZqJRFjke5tol7Uw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)