PHPStorm cache on virtual RAM disk [MacOS]

When using a SSD disk, and enough RAM on the system, I always prefer to move software cache files into a virtual RAM disk, in order to extend the disk life, and also gain more speed.

The command on MacOs to create a 512Mb Virtual volume (under /Volumes/RAMDisk) is

diskutil erasevolume HFS+ 'RAMDisk' `hdiutil attach -nomount ram://524288`;

After that, you can create your symlink, and move that command in a startup script

PHPStorm script

Here is the script I’m using to create the virtual Disk and the index and cache directories for PHPStorm. Of course you need to symlink them the first time you use them (see the comments in the gist).

You’ll lose the cache and index next time you restart your computer or unmount your RAMDisk, but that’s something I actually prefer, to keep the cache clean from old projects and libraries.