Thread safe caching of global data