UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'C0jdi5YBpxl3zjOsuEyWLi4g6OCO2MZwghY4nuxoAJ8='
WHERE
key_id = '583e4a0f534bc8b14377d2f71f487b28587c7f0329b34998ae338f16262f91dd'
AND (
token = 'C0jdi5YBpxl3zjOsuEyWLi4g6OCO2MZwghY4nuxoAJ8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)