Synchronise the application configuration with the cache.
@param cache The provider cache
@return <CODE>true</CODE> if the operation was successful
331710
public boolean syncApplications(NewRelicCache cache)
    {
        boolean ret = true;

        if(apiClient == null)
            throw new IllegalArgumentException("null API client");

        // Get the application configuration using the REST API
        if(cache.isApmEnabled() || cache.isBrowserEnabled() || cache.isMobileEnabled())
        {
            ret = false;

            if(cache.isApmEnabled())
            {
                logger.info("Getting the applications");
                Collection<Application> applications = apiClient.applications().list();
                for(Application application : applications)
                {
                    cache.applications().add(application);

                    logger.fine("Getting the hosts for application: "+application.getId());
                    cache.applications().applicationHosts(application.getId()).add(apiClient.applicationHosts().list(application.getId()));

                    logger.fine("Getting the instances for application: "+application.getId());
                    cache.applications().applicationHosts(application.getId()).addApplicationInstances(apiClient.applicationInstances().list(application.getId()));

                    logger.fine("Getting the deployments for application: "+application.getId());
                    cache.applications().deployments(application.getId()).add(apiClient.deployments().list(application.getId()));
                }

                // Get the key transaction configuration using the REST API
                try
                {
                    logger.info("Getting the key transactions");
                    cache.applications().addKeyTransactions(apiClient.keyTransactions().list());
                }
                catch(ErrorResponseException e)
                {
                    if(e.getStatus() == 403) // throws 403 if not allowed by subscription
                        logger.warning("Error in get key transactions: "+e.getMessage());
                    else
                        throw e;
                }
            }

            if(cache.isBrowserEnabled())
            {
                logger.info("Getting the browser applications");
                cache.browserApplications().add(apiClient.browserApplications().list());
            }

            if(cache.isBrowserEnabled())
            {
                logger.info("Getting the mobile applications");
                cache.mobileApplications().add(apiClient.mobileApplications().list());
            }

            cache.setUpdatedAt();

            ret = true;
        }

        return ret;
    }
108533
protected boolean isProcessingBundleFromCacheMapping() {
		boolean processBundleFromCacheMapping = false;
		if (jawrConfig.getUseBundleMapping() && resourceBundleHandler.isExistingMappingFile()) {
			Properties cachedMappingProperties = resourceBundleHandler.getJawrBundleMapping();
			String storedHashcode = cachedMappingProperties.getProperty(JawrConstant.JAWR_CONFIG_HASHCODE);
			String currentHashcode = null;
			try {
				currentHashcode = CheckSumUtils.getMD5Checksum(jawrConfig.getConfigProperties().toString());
			} catch (IOException e) {
				throw new BundlingProcessException("Unable to calculate checksum for current Jawr config");
			}
			if (currentHashcode.equals(storedHashcode)) {
				processBundleFromCacheMapping = true;
			}
		}
		return processBundleFromCacheMapping;
	}
184658
protected function instantiateCache(Cache $cache = null)
    {
        if (is_null($this->cache) || ! is_null($cache)) {
            $this->cache = ! is_null($cache)
                ? $cache
                : new Cache($this->config);
        }

        return $this->cache;
    }
653288
public <K, V> AdvancedCache<K, V> decorateCache(AdvancedCache<K, V> cache) {
      return cache.transform(this::transform);
   }
823741
private void updatedCache(final ClassLoader classLoader, final Set<TraceeBackendProvider> provider) {
		final Map<ClassLoader, Set<TraceeBackendProvider>> copyOnWriteMap = new WeakHashMap<>(providersPerClassloader);
		if (!provider.isEmpty()) {
			copyOnWriteMap.put(classLoader, new BackendProviderSet(provider));
		} else {
			copyOnWriteMap.put(classLoader, new EmptyBackendProviderSet());
		}
		providersPerClassloader = copyOnWriteMap;
	}
413275
public @Nullable <K, V> CacheProxy<K, V> tryToCreateFromExternalSettings(String cacheName) {
    Optional<CaffeineConfiguration<K, V>> configuration =
        TypesafeConfigurator.from(rootConfig, cacheName);
    return configuration.isPresent() ? createCache(cacheName, configuration.get()) : null;
  }
1035790
public boolean containsKey(Object key) {
        if( !cache.containsKey(key) ) {
            return false;
        }
        else {
            SoftReference<T> ref = cache.get(key);
            T ob = ref.get();
            
            if( ob == null ) {
                release(key);
                return false;
            }
            if( ob instanceof CachedItem ) {
                if( !((CachedItem)ob).isValidForCache() ) {
                    release(key);
                    return false;
                }
            }
            return true;
        }
    }
1072087
@Override
    public <K, V> Cache<K, V> getCache(String cacheName) {
        return this.getCache(cacheName, true);
    }
879990
public static QueryCache getQueryCache(Cache<?, ?> cache) {
      return SecurityActions.getCacheGlobalComponentRegistry(cache.getAdvancedCache()).getComponent(QueryCache.class);
   }
973688
public boolean syncAlerts(NewRelicCache cache)
    {
        boolean ret = true;

        if(apiClient == null)
            throw new IllegalArgumentException("null API client");

        // Get the alert configuration using the REST API
        if(cache.isAlertsEnabled())
        {
            ret = false;

            // Get the alert policies
            logger.info("Getting the alert policies");
            Collection<AlertPolicy> policies = apiClient.alertPolicies().list();
            for(AlertPolicy policy : policies)
            {
                cache.alertPolicies().add(policy);

                // Add the alert conditions
                if(cache.isApmEnabled() || cache.isServersEnabled() || cache.isBrowserEnabled() || cache.isMobileEnabled())
                    cache.alertPolicies().alertConditions(policy.getId()).add(apiClient.alertConditions().list(policy.getId()));
                cache.alertPolicies().nrqlAlertConditions(policy.getId()).add(apiClient.nrqlAlertConditions().list(policy.getId()));
                if(cache.isApmEnabled() || cache.isMobileEnabled())
                    cache.alertPolicies().externalServiceAlertConditions(policy.getId()).add(apiClient.externalServiceAlertConditions().list(policy.getId()));
                if(cache.isSyntheticsEnabled())
                    cache.alertPolicies().syntheticsAlertConditions(policy.getId()).add(apiClient.syntheticsAlertConditions().list(policy.getId()));
                if(cache.isPluginsEnabled())
                    cache.alertPolicies().pluginsAlertConditions(policy.getId()).add(apiClient.pluginsAlertConditions().list(policy.getId()));
                if(cache.isInfrastructureEnabled())
                    cache.alertPolicies().infraAlertConditions(policy.getId()).add(infraApiClient.infraAlertConditions().list(policy.getId()));
            }

            // Get the alert channels
            logger.info("Getting the alert channels");
            Collection<AlertChannel> channels = apiClient.alertChannels().list();
            cache.alertChannels().set(channels);
            cache.alertPolicies().setAlertChannels(channels);
            cache.setUpdatedAt();

            ret = true;
        }

        return ret;
    }
1182516
public void clear(NewRelicCache cache)
    {
        if(cache == null)
            throw new IllegalArgumentException("null cache");
        cache.applications().clear();
        cache.browserApplications().clear();
        cache.mobileApplications().clear();
        cache.plugins().clear();
        cache.monitors().clear();
        cache.servers().clear();
        cache.entities().clear();
        cache.alertPolicies().clear();
        cache.alertChannels().clear();
        cache.dashboards().clear();
    }
795388
public void initialize(NewRelicCache cache)
    {
        String apiKey = cache.getApiKey();
        if(apiKey == null)
            throw new IllegalArgumentException("null API key");

        logger.info("Initialising the clients");

        initialized = false;
        if(cache.isAlertsEnabled())
        {
            apiClient = NewRelicApi.builder().apiKey(apiKey).build();
            infraApiClient = NewRelicInfraApi.builder().apiKey(apiKey).build();
            syntheticsApiClient = NewRelicSyntheticsApi.builder().apiKey(apiKey).build();
        }

        logger.info("Initialised the clients");

        initialized = true;
    }
376444
protected Object getFromCache(String cacheName, String key) {
        try {
            ICache cache = getCache(cacheName);
            return cache != null ? cache.get(key) : null;
        } catch (CacheException e) {
            LOGGER.warn(e.getMessage(), e);
            return null;
        }
    }
382125
public static Single<Boolean> set(String cacheKey, int index, Object value) {
        return set(CacheService.CACHE_CONFIG_BEAN, cacheKey, index, value);
    }
960434
@Override
	protected void resetCache() {
		super.resetCache();
		cacheProperties.put(JAWR_SERVLET_MAPPING, config.getServletMapping());
		String binaryServletMapping = getBinaryServletMapping();
		if (binaryServletMapping != null) {
			cacheProperties.put(JAWR_BINARY_SERVLET_MAPPING, binaryServletMapping);
		} else {
			cacheProperties.remove(JAWR_BINARY_SERVLET_MAPPING);
		}
		cacheProperties.put(JawrConfig.JAWR_CSS_CLASSPATH_HANDLE_IMAGE,
				Boolean.toString(config.isCssClasspathImageHandledByClasspathCss()));
		cacheProperties.put(JawrConfig.JAWR_BINARY_HASH_ALGORITHM, config.getBinaryHashAlgorithm());
	}
356297
static StorageCache initCache(Configuration configuration) {
    if (configuration.getBoolean(Configuration.CACHE_ENABLED) && configuration.getLong(Configuration.CACHE_BYTES) > 0) {
      return new StorageCache(configuration);
    } else {
      return new DisabledCache();
    }
  }
857301
public boolean remove(K key) {
        if (null == key)
            return false;
        CacheReference<K> keyRef = lookupFactory.createKey(key, queue);
        return CacheKey.class.cast(keyRef).removeCacheEntry();
    }