Fetches a cache instance if available in instanceMap. If instance is not available in
instanceMap, it calls createCacheInstance() to create a new cache instance.

@returns {cacheInstance}
193197
function(configStrategy) {
    let instanceKey = getInstanceKey(configStrategy);

    let _instance = instanceMap[instanceKey];

    if (!_instance) {
      _instance = new OSTCache(configStrategy);
      instanceMap[instanceKey] = _instance;
    }

    return _instance;
  }
1267726
function createLocalCache() {
    var localCache = lruCache({ max: 100, maxAge: 60000 });
    return {
        get: function (key) {
            return new Q(localCache.get(key));
        },
        set: function (key, value) {
            localCache.set(key, value);
        },
        del: function (key) {
            localCache.set(key, null);
        }
    };
}
1196915
private CacheEntry getCacheEntry(Object value, boolean create)
  {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(
        this,cclass,
        "getCacheEntry",
        new Object[] { value, new Boolean(create), matchCache });

    CacheEntry e = (CacheEntry) matchCache.get(value);
    if (e == null)
    {
      if (create)
      {
        e = new CacheEntry();
        // The following method call may stimulate multiple callbacks to the shouldRetain
        // method if the Hashtable is at the rehash threshold.
        matchCache.put(value, e);
        cacheCreates++;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "getCacheEntry", e);

    return e;
  }
66936
public static function getInstance()
    {
        if (null === self::$_instance) {
        
            $app = \Cetera\Application::getInstance();
        
            if ($app->getVar('cache_memcache')!='off' && $app->getVar('cache_memcache')!='disable' && $app->getVar('cache_memcache')!='0' && self::isMemcacheAvailable()) {
				$o = [];
				if ( $app->getVar('memcache_server') ) {
					$o['servers'] = $app->getVar('memcache_server');
				}
                $backend = new \Dklab_Cache_Backend_TagEmuWrapper(new \Zend_Cache_Backend_Memcached($o));
			}
            elseif ($app->getVar('cache_memcached')!='off'&& $app->getVar('cache_memcached')!='disable' && $app->getVar('cache_memcached')!='0' && self::isMemcachedAvailable()) {
				$o = [];
				if ( $app->getVar('memcached_server') ) {
					$o['servers'] = $app->getVar('memcached_server');
				}				
                $backend = new \Dklab_Cache_Backend_TagEmuWrapper(new \Zend_Cache_Backend_Libmemcached($o));				
            } 
			elseif ($app->getVar('cache_file') && self::isFilecacheAvailable()) {
                $backend = new \Zend_Cache_Backend_File(array('cache_dir'=>FILECACHE_DIR, 'hashed_directory_level'=>1));
            } 
			else {
                $backend = new BackendNull();
            }
        
            self::$_instance = new Profiler($backend);
        }
        return self::$_instance;
    }
1019442
protected Object getCacheManager() {
        CacheManager cacheManager = CacheManager.getInstance();
        if (cacheManager != null)
            return cacheManager;
        return CacheManager.newInstance();
    }
422724
@Nonnull
  @ReturnsMutableCopy
  @OverrideOnDemand
  @CodingStyleguideUnaware
  protected ICommonsMap <KEYTYPE, VALUETYPE> createCache ()
  {
    return hasMaxSize () ? new SoftLinkedHashMap <> (m_nMaxSize) : new SoftHashMap <> ();
  }
1143687
public V getCachedObject(TaskRequest req, TaskResponse res, K key, Factory<K, V> factory) {
        final CacheMode cacheMode = CacheMode.valueOf((String) this.cacheModelPhrase.evaluate(req, res));
        
        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Getting cached object for '" + key + "' using cache mode " + cacheMode + " and factory " + factory);
        }
        
        //Load the cache only if cache-all is enabled
        final ConcurrentMap<Tuple<Serializable, K>, Object> cache;
        final Tuple<Serializable, K> compoundCacheKey;
        switch (cacheMode) {
            case NONE: {
                return factory.createObject(key);
            }
            
            default:
            case ONE: {
                cache = null;
                compoundCacheKey = null;
            }
            break;
            
            case ALL: {
                cache = (ConcurrentMap<Tuple<Serializable, K>, Object>) this.cachePhrase.evaluate(req, res);
                final Serializable cacheNamespace = factory.getCacheNamespace(key);
                compoundCacheKey = new Tuple<Serializable, K>(cacheNamespace, key);
            }
            break;
        }
        
        //Determine the object to synchronize around
        final Object syncTarget = factory.getMutex(key);

        //get or create & cache the target object
        V instance = null;
        synchronized (syncTarget) {
            //Get the object from the local variables if no cache is available
            if (cache == null) {
                //Try for a thread-local instance first
                if (this.compareKeys(key, this.threadKeyHolder.get())) {
                    instance = this.threadInstanceHolder.get();
                }
                //Next try for a singleton instance
                else if (this.compareKeys(key, this.key)) {
                    instance = this.instance;
                } 
            }
            //Look in the passed cache for the instance
            else {
                final Object object = cache.get(compoundCacheKey);
                
                //If the cached object is a ThreadLocal use it for the instance
                if (object instanceof ThreadLocal<?>) {
                    instance = ((ThreadLocal<V>) object).get();
                }
                //If not assume it is the instance 
                else {
                    instance = (V) object;
                }
            }
            
            //If no instance was found create and cache one
            if (instance == null) {
                instance = factory.createObject(key);
                final boolean threadSafe = factory.isThreadSafe(key, instance);
                
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("Cache miss for '" + key + "' created '" + instance + "' threadSafe=" + threadSafe);
                }
                
                //If no cache is available store the instance in the local variables
                if (cache == null) {
                    if (threadSafe) {
                        this.instance = instance;
                        this.key = key;
                    }
                    else {
                        this.threadInstanceHolder.set(instance);
                        this.threadKeyHolder.set(key);
                    }
                }
                //Cache available store there
                else {
                    if (threadSafe) {
                        cache.put(compoundCacheKey, instance);
                    }
                    else {
                        ThreadLocal<V> threadInstanceHolder = (ThreadLocal<V>)cache.get(compoundCacheKey);
                        if (threadInstanceHolder == null) {
                            threadInstanceHolder = new ThreadLocal<V>();
                            
                            while (true) {
                                Object existing = cache.putIfAbsent(compoundCacheKey, threadInstanceHolder);
                                if (existing == null) {
                                    //nothing existed for that key, put was successful
                                    break;
                                }
                                
                                if (existing instanceof ThreadLocal) {
                                    //Existing ThreadLocal, just use it
                                    threadInstanceHolder = (ThreadLocal)existing;
                                    break;
                                }
                                
                                //something other than a ThreadLocal already exists, try replacing with the ThreadLocal
                                final boolean replaced = cache.replace(compoundCacheKey, threadInstanceHolder, existing);
                                if (replaced) {
                                    //Replace worked!
                                    break;
                                }
                                
                                //Replace didn't work, try the whole process again, yay non-blocking!
                            }
                            
                            if (cache instanceof EvictionAwareCache) {
                                ((EvictionAwareCache) cache).registerCacheEvictionListener(ThreadLocalCacheEvictionListener.INSTANCE);
                            }
                        }

                        threadInstanceHolder.set(instance);
                    }
                }
            }
            else if (this.logger.isDebugEnabled()) {
                this.logger.debug("Cache hit for '" + key + "' using '" + instance + "'");
            }
        }
        
        return instance;
    }
511030
function (key, instance) {
            if (arguments.length == 1) {
                instance = key;
                key = null;
            }

            if (key) {
                this.$singletonInstanceCache[key] = instance;
            } else {
                this.$singletonInstanceCache.push(instance);
            }


        }
109723
private Map<ServiceInstanceToken, InstanceHealthPair> getCacheServiceInstances() {
        if (instanceCache == null) {
            synchronized (this) {
                if (instanceCache == null) {
                    instanceCache = new ConcurrentHashMap<ServiceInstanceToken, InstanceHealthPair>();
                    initJobTasks();
                }
            }
        }
        return instanceCache;
    }
805080
public static function getInstance($name)
    {
        if (!isset(static::$instances[$name])) {
            static::$instances[$name] = new CacheInstance();
        }
        return static::$instances[$name];
    }
1125285
private ServiceDirectoryCache<String, ModelService> getCache(){
        if(cache == null){
            synchronized (this) {
                if (this.cache == null) {
                    this.cache = new ServiceDirectoryCache<String, ModelService>();
                }
            }
        }
        return this.cache;
    }
959310
@JsonIgnore
    public PrincipalAttributesRepositoryCache getCacheInstanceFromApplicationContext() {
        val ctx = ApplicationContextProvider.getApplicationContext();
        return ctx.getBean("principalAttributesRepositoryCache", PrincipalAttributesRepositoryCache.class);
    }
262969
function ExecutionCache() {
  var cache = {};

  function getKey(query) {
    return query.queryKey + '(' + JSON.stringify(query.queryParams) + ')'
  }

  function get(query) {
    return cache[getKey(query)]
  }

  this.execute = function (query) {
    var query = _.cloneDeep(query);
    var execution = get(query);
    if (execution) {
      var requestedKeys = _.keys(query.shape);
      if (_.intersection(_.keys(execution.shape), requestedKeys).length != requestedKeys.length) {
        // TODO we probably should also merge the nested shape
        var newShape = _.assign(execution.shape, query.shape);
        query.shape = newShape;
        execution = {
          shape: newShape,
          promise: getHandler(query.name, query.queryKey)(query.shape, query.queryParams, query.type)
        }
      }
    } else {
      execution = {
        shape: query.shape,
        promise: getHandler(query.name, query.queryKey)(query.shape, query.queryParams, query.type)
      };
    }
    cache[getKey(query)] = execution;
    return execution;
  };

  this.get = get;
  this.getKey = getKey;
  return this;
}
76677
private static ResourceCache loadResourceCache() {
        try {
            return Optional.ofNullable(Bootstrap.getService(ResourceCache.class)).orElseGet(
                    DefaultResourceCache::new);
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "Error loading ResourceCache instance.", e);
            return new DefaultResourceCache();
        }
    }
899951
public static function getInstance() {
		if (is_null(self::$_instance)) {
			$id_cache = is_memcache_available() ? new Memcache() : new FileCache();
			self::$_instance = new self($id_cache);
		}
		return self::$_instance;
	}
1148481
private static ResourceCache loadResourceCache() {
        try {
            ResourceCache cache = Bootstrap.getService(ResourceCache.class);
            if (cache == null) {
                cache = new DefaultResourceCache();
            }
            return cache;
        } catch (Exception e) {
            LOG.log(Level.SEVERE, "Error loading ResourceCache instance.", e);
            return new DefaultResourceCache();
        }
    }
441753
function findOrCreateInstance(callback) {
    var models = self._meshApp.models;
    var Instance = models.ServiceInstance;

    service.instances(function(err, instances) {
      if (err) return callback(err);
      if (instances.length > 0) return callback();

      debug('onServiceUpdate: create first instance');

      var instance = new Instance({
        executorId: 1,
        serverServiceId: service.id,
        groupId: 1,
        cpus: 'STRONGLOOP_CLUSTER' in process.env ?
          process.env.STRONGLOOP_CLUSTER : 'CPU',

        // allow starting tracing on all instances via env for testing purposes
        tracingEnabled: !!process.env.STRONGLOOP_TRACING || false,
      });
      instance.save(callback);
    });
  }