Add cache support for getDirectories() method and refactor

* Cache support for getDirectories() added.
* Added memoize() method to avoid code duplication related to cache implementation
* Renamed methods to avoid redundant "module"

Hope you find it useful!
I've got the feeling that we should be using `\ArrayObject` as well.