The way you did it will work (and, I guess, it will be a bit better in terms of the performance). However, runBuildCacheHandler() is not the place that you look into when investigating why the menu is not displayed on the page
Your way may be confusing for other developers customizing your code later.