UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'MgoqFkavVfjrBOMZFTcktMxm5rdNxY5lHP2W1ty7i1g='
WHERE
key_id = '40fa9490fc0fcdf187c302786616bc18159998e0e243038e85a65a247c3b8219'
AND (
token = 'MgoqFkavVfjrBOMZFTcktMxm5rdNxY5lHP2W1ty7i1g='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)