UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'hRjgtLwUiIeucMB17wjoKlAmXhLskZW2qxwjPmm8CK8='
WHERE
key_id = '6f46991476e036cda22b7f8ed35f6bf4aa4053a8c8b7b1a04c0897df0f4f2e9e'
AND (
token = 'hRjgtLwUiIeucMB17wjoKlAmXhLskZW2qxwjPmm8CK8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)