Re-generate autoloader cache when cached file does not exists (closes #2508)

Also:
- Atomically write the `.autoloader.cache` file.
- Re-generation is locked in order to prevent multiple processes from
  re-indexing the files.
Merge pull request #588 from eguaj/3.2-A2508

Re-generate autoloader cache when cached file does not exists (closes #2508)