UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '7h0z+bndIEJFyxOsjGkGuZSML0fNh6O5Kl1cks7Ut38='
WHERE
key_id = 'cc5135db6c9524438a20655948019f147f6fec8c588d7866c7d02854447599a3'
AND (
token = '7h0z+bndIEJFyxOsjGkGuZSML0fNh6O5Kl1cks7Ut38='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)