Locally finite + quasi-compact versus finite

Let $f: X \rightarrow Y$ be a morphism of, say, locally noetherian schemes. Suppose that $f$ is locally finite (that is for every open affine subset $U= spec A$ of $Y$, $f^{-1}(U)$ can be covered by open affine subsets $V_i=spec B_i$ such that each $B_i$ is a finitely generated $A$-module), and quasi-compact (so in the above one can assume that there are finitely many $V_i$ as abovecovering $f^{-1}(U)$). Then does it imply that $f$ is finite? I don't think that's true, but I'd like a counter-example (or if it is true, a proof or reference). Thanks.

This is not true, because you are not assuming that $f$ is separated. E.g. let $Y$ be the affine line, let $X$ be the affine line with a doubled origin, then $X \to Y$ is not affine (not even separated), in particular not finite, but it is locally finite and q.c.
However, locally finite q.c. morphisms are quasi-finite and closed. We may check this locallly on the target, and so we may replaced $Y$ by $U$ and $X$ by $f^{-1}(U)$, and hence assume that $Y$ is affine. Let us also write $V$ for the disjoint union of the $V_i$ covering $X$.
Then we have the factorization $V \to X \to Y$, the first morphism being surjective, and the composite being finite. The morphism $X \to Y$ is then quasi-finite, and closed. (The first property is clear, and the second property follows from the fact that the image of a closed set in $X$ is also the image of its preimage in $V$ (by surjectivity of $V \to X$), and this latter image is closed, since finite morphisms are closed.)
Thus the statement is true if you assume that $f$ is also separated.