Spring Framework Cache - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework Cache class.

This code example shows how to use the following methods:get, put
 
	@Override 
	public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) 
			throws IOException { 
 
		Resource transformed = this.cache.get(resource, Resource.class); 
		if (transformed != null) { 
			if (logger.isTraceEnabled()) { 
				logger.trace("Found match"); 
			} 
			return transformed; 
		} 
 
		transformed = transformerChain.transform(request, resource); 
 
		if (logger.isTraceEnabled()) { 
			logger.trace("Putting transformed resource in cache"); 
		} 
		this.cache.put(resource, transformed); 
 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get
	 * miss in case of error. 
	 * @see Cache#get(Object) 
	 */ 
	protected Cache.ValueWrapper doGet(Cache cache, Object key) {
		try { 
			return cache.get(key);
		} 
		catch (RuntimeException e) {
			getErrorHandler().handleCacheGetError(e, cache, key);
			return null; // If the exception is handled, return a cache miss 
		} 
	} 
 
	/** 
	 * Execute {@link Cache#put(Object, Object)} on the specified {@link Cache} 
	 * and invoke the error handler if an exception occurs. 
	 */ 
	protected void doPut(Cache cache, Object key, Object result) {
		try { 
			cache.put(key, result);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:get, put
	@Override 
	protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, 
			List<? extends Resource> locations, ResourceResolverChain chain) { 
 
		String key = RESOLVED_RESOURCE_CACHE_KEY_PREFIX + requestPath; 
		Resource resource = this.cache.get(key, Resource.class); 
 
		if (resource != null) { 
			if (logger.isTraceEnabled()) { 
				logger.trace("Found match"); 
			} 
			return resource; 
		} 
 
		resource = chain.resolveResource(request, requestPath, locations); 
		if (resource != null) { 
			if (logger.isTraceEnabled()) { 
				logger.trace("Putting resolved resource in cache"); 
			} 
			this.cache.put(key, resource); 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getName
 
 
	// Common cache initialization delegates/callbacks 
 
	protected final void addCache(Cache cache) {
		this.cacheMap.put(cache.getName(), decorateCache(cache));
		this.cacheNames.add(cache.getName());
	} 
 
	protected final Cache lookupCache(String name) {
		return this.cacheMap.get(name);
	} 
 
	/** 
	 * Decorate the given Cache object if necessary. 
	 * @param cache the Cache object to be added to this CacheManager 
	 * @return the decorated Cache object to be used instead, 
	 * or simply the passed-in Cache object by default 
	 */ 
	protected Cache decorateCache(Cache cache) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Spring Framework Cache Methods: