Fix for the cache's file driver - added some protections to race conditions.
Merge pull request #1446 from Martynas-P/master

Fix for the cache's file driver - added some protections to race conditions.