Move cache set into else block to improve readability