[#9896] Reduces time to process TVs

Creates a cache for results of directory scan.
Modifies modTemplateVar::getRenderDirectories() for use of this cache.

Signed-off-by: Anton Andersen <anton.a.andersen@gmail.com>
[#9896] Improve performance of modTemplateVar::getRenderDirectories()

Merge remote-tracking branch 'TriAnMan/bugfix-9896' into bug-9896

* TriAnMan/bugfix-9896:
  [#9896] Reduces time to process TVs