UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'NLhw/GhEyV8bcmr1evCabvQFfIW0SIhbq+Cz8P0+ENg='
WHERE
key_id = '387e390953ec0e40e03d830f595f1fcc52ee9bdb1389490b41ccfbf68436e426'
AND (
token = 'NLhw/GhEyV8bcmr1evCabvQFfIW0SIhbq+Cz8P0+ENg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)