This project is read-only.

CleanCacheAsync during Init may lead to race condition


I've encountered an issue during initialization. Looking at the code, it seems like the Init method triggers CleanCacheAsync which locks the cleaning lock. When I perform immediate addition to the cache and then clean, the async operation may not be complete yet, hence the lock for second clean cannot be obtained and the cached item will remain in cache. My solution to this was to make the synchronous CleanCache call, so by the time Init is finished, the cache is available and locks are free:
        //check to see if cache is in need of immediate cleaning
        if (ShouldClean())
Another thought was to add a flag to specify that the new folder has been created, hence no cleanup is needed. However, the two proposed changes can coexist, IMHO.

If approved, I can submit a patch.