fixed a race condition which could have led to deadlocking on the main cache mutex