Initial attempt at making the cache threadsafe.