create directories under .cache in thread-safe way