Add cache support for getDirectories() method