UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'GRkHO+ad5cfWo0ckeCiXBT3Yy3vW2hfbz30TotHP3G8='
WHERE
key_id = 'ad1375caa495d9b08a370462b47b9d3a57dac6c36badf35b49b621bf237adb5a'
AND (
token = 'GRkHO+ad5cfWo0ckeCiXBT3Yy3vW2hfbz30TotHP3G8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)