Psalm 12, like plenty of other Psalms have both a Davidic-historical-general mode of interpretation, as well as a prophecy-future-specific fulfilment.
Psalm 12:7 “this generation for ever.”
This can mean from David’s time in the first way of interpreting. But we must remember, the Scripture is from the Holy Ghost: you shouldn’t just limit it to the milieu, perspective, culture, time, context or mindset of David.
In this way, it would mean that the promise of God would be seen fulfilled in the future, prophetic fulfillment.
We find in Psalm 12, where it says, “The words of the LORD are pure words”, that prophecy is eternal in perspective, and that the process of refining was declared from ancient times, and that the pure text-and-translation was ordained of old.
This is because these these principles are taken:
Isaiah 46:10 Declaring the end from the beginning, and from ancient times the things that are not yet done, saying, My counsel shall stand, and I will do all my pleasure:
Romans 4:17b …and calleth those things which be not as though they were.
Thus, this psalm is both a general statement about the word of God from David’s time on, or is a prophecy about a specific time period in history, where there has been a refining of the text and translation of the Scripture with the King James Bible.
The two modes of interpretation do not contradict each other, but go hand in hand. Especially since when it says “Thou shalt keep them, O LORD”, it would mean keeping the people of God in connection and for the sake of His word and by His promise (the words) in the evil generation, particularly in the prophetic sense.