Verse 21. But the Lord was with Joseph and shewed him mercy. God despiseth not his prisoners, Psalm lxix, 33. No gates nor bars can shut out his gracious presence from his people. God gave him favour in the sight of the keeper of the prison - God can raise up friends for his people even where they little expect them. The keeper saw that God was with him, and that every thing prospered under his hand, and therefore intrusted him with the management of the affairs of the prison.