Cache the ThreadLocal RawStore object. Called from the corresponding thread.
558266
public void cacheThreadLocalRawStore() {
    Long threadId = this.getId();
    RawStore threadLocalRawStore = HiveMetaStore.HMSHandler.getRawStore();
    if (threadLocalRawStore != null && !threadRawStoreMap.containsKey(threadId)) {
      LOG.debug("Adding RawStore: " + threadLocalRawStore + ", for the thread: " +
          this.getName() + " to threadRawStoreMap for future cleanup.");
      threadRawStoreMap.put(threadId, threadLocalRawStore);
    }
  }
1266348
@SuppressWarnings("rawtypes")
    protected List cacheLoadOrStore(List<Object> loadedObjects) {
        if (loadedObjects.isEmpty()) {
            return loadedObjects;
        }
        if (!(loadedObjects.get(0) instanceof Entity)) {
            return loadedObjects;
        }

        List<Entity> filteredObjects = new ArrayList<Entity>(loadedObjects.size());
        for (Object loadedObject : loadedObjects) {
            Entity cachedEntity = cacheLoadOrStore((Entity) loadedObject);
            filteredObjects.add(cachedEntity);
        }
        return filteredObjects;
    }
527519
def patch_related_object_descriptor_caching(ro_descriptor):
    
    class NewSingleObjectDescriptor(LanguageCacheSingleObjectDescriptor, ro_descriptor.__class__):
        pass

    if django.VERSION[0] == 2:
        ro_descriptor.related.get_cache_name = partial(
            NewSingleObjectDescriptor.get_cache_name,
            ro_descriptor,
        )

    ro_descriptor.accessor = ro_descriptor.related.get_accessor_name()
    ro_descriptor.__class__ = NewSingleObjectDescriptor
22432
def set_threadlocal(self, **values):
        """"""
        with self._lock:
            self._ensure_threadlocal()
            self._tpayload.context = values
1356583
public final void removeThreadLocal(Object key)
    {
        if (sealed) onSealedMutation();
        if (threadLocalMap == null)
            return;
        threadLocalMap.remove(key);
    }
1368636
def do_api_calls_update_cache(self):
        '''  '''
        zones = self.parse_env_zones()
        data = self.group_instances(zones)
        self.cache.write_to_cache(data)
        self.inventory = data
629448
def thread_local(name, default_value = nil)
      is_a?(Module) or raise TypeError, "receiver has to be a Module"

      name = name.to_s
      my_id = "__thread_local_#{__id__}__"

      ObjectSpace.define_finalizer(self, @@cleanup)

      define_method(name) do
        Thread.current[my_id] ||= {}
        Thread.current[my_id][name]
      end

      define_method("#{name}=") do |value|
        Thread.current[my_id] ||= {}
        Thread.current[my_id][name] = value
      end

      if default_value
        Thread.current[my_id] = {}
        Thread.current[my_id][name] = default_value
      end
      self
    end
294267
def push_thread_local_value(name, value) #:nodoc:
      save_val = thread_local_value(name)
      set_thread_local_value(name, value)
      begin
        yield
      ensure
        set_thread_local_value(name, save_val)
      end
    end
486329
def set_object_cache(self, notify_func=None, getbuffer_func=None):
        
        self._object_cache_notify = notify_func
        self._object_cache_getbuffer = getbuffer_func
        # Lifetime of the object cache is managed by us.
        self._object_cache = _ObjectCacheRef(self)
        # Note this doesn't keep a reference to self, to avoid reference
        # cycles.
        ffi.lib.LLVMPY_SetObjectCache(self, self._object_cache)
1177068
def cache(self, f):
        """"""
        if self._memory is None:  # pragma: no cover
            logger.debug("Joblib is not installed: skipping cacheing.")
            return f
        assert f
        # NOTE: discard self in instance methods.
        if 'self' in inspect.getargspec(f).args:
            ignore = ['self']
        else:
            ignore = None
        disk_cached = self._memory.cache(f, ignore=ignore)
        return disk_cached
334933
public void setThreadContextLoader() {
        if (isContextLoaderSaved) {
            throw new BuildException("Context loader has not been reset");
        }
        if (LoaderUtils.isContextLoaderAvailable()) {
            savedContextLoader = LoaderUtils.getContextClassLoader();
            ClassLoader loader = this;
            if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
                loader = this.getClass().getClassLoader();
            }
            LoaderUtils.setContextClassLoader(loader);
            isContextLoaderSaved = true;
        }
    }
1017540
private synchronized static void loadAll() throws DaoManagerException {
		if (setImpl ==null) {
			long implLastModifiedTime=impl.getLastModified();
				
			if (lastModified<implLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);	
			}
		} else {
			long implLastModifiedTime=impl.getLastModified();
			long setImplLastModifiedTime=setImpl.getLastModified();
		
			if (lastModified<implLastModifiedTime || lastModified<setImplLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				Map<String,PropertyDescriptor> dynamicValues=setImpl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
					cache.putAll(dynamicValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);
			}
		}
	}
926421
def context_cache(func):
    '''
    
    '''
    def context_cache_wrap(*args, **kwargs):
        func_context = func.__globals__['__context__']
        func_opts = func.__globals__['__opts__']
        func_name = func.__globals__['__name__']

        context_cache = ContextCache(func_opts, func_name)
        if not func_context and os.path.isfile(context_cache.cache_path):
            salt.utils.dictupdate.update(func_context, context_cache.get_cache_context())
        else:
            context_cache.cache_context(func_context)
        return func(*args, **kwargs)
    return context_cache_wrap
632383
def update_cache_key(cls, cache_key, item=None):
        
        contents = cls.__thread_id_cache.get(cache_key, None)
        if item is not None:
            cls.__thread_id_cache[cache_key] = item

        return contents
62911
def persist(self, storageLevel):
        
        self.is_cached = True
        javaStorageLevel = self._sc._getJavaStorageLevel(storageLevel)
        self._jdstream.persist(javaStorageLevel)
        return self
9239
private void cacheClass(ClassSource classSource, String outerClassName) {
        if (classCacheMode != UserCodeDeploymentConfig.ClassCacheMode.OFF) {
            classSourceMap.put(outerClassName, classSource);
        } else {
            ThreadLocalClassCache.store(outerClassName, classSource);
        }
    }
566399
private void populateLocalCache() {
      try (CloseableIterator iterator = cache.keySet().iterator()) {
         while (iterator.hasNext()) {
            getFromCache(iterator.next(), null);
         }
      }
   }