UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'mg882wUID4TujGidVvPk1WX1othn7aunuQYyE7u6ph8='
WHERE
key_id = 'a37de54451355e05ae15863d5cac7ef421ab1d011e2f1b182a8f1f5aca55b0a4'
AND (
token = 'mg882wUID4TujGidVvPk1WX1othn7aunuQYyE7u6ph8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)