Make DefinitionCache thread safe

There could be a thread switch in between the call to `containsKey()` and the call to `get()`