/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
Ehcache backingCache = getCache(); Element element = backingCache.get(key); element = super.get(key); } else { Sync lock = getLockForKey(key); try { lock.lock(LockType.WRITE); update(key); } finally { lock.unlock(LockType.WRITE); } catch (final Throwable throwable) { put(new Element(key, null)); throw new LockTimeoutException("Could not update object for cache entry with key \"" + key + "\".", throwable);
/** * Element can never be null. Add a null guard just in case. * @param key */ protected void update(final Object key) { try { Ehcache backingCache = getCache(); final Element element = backingCache.getQuiet(key); if (element == null) { if (LOG.isDebugEnabled()) { LOG.debug(getName() + ": entry with key " + key + " has been removed - skipping it"); } return; } refreshElement(element, backingCache); } catch (final Exception e) { // Collect the exception and keep going. // Throw the exception once all the entries have been refreshed // If the refresh fails, keep the old element. It will simply become staler. LOG.warn(getName() + "Could not refresh element " + key, e); } }
Ehcache backingCache = getCache(); Element element = backingCache.get(key); element = super.get(key); } else { Sync lock = getLockForKey(key); try { lock.lock(LockType.WRITE); update(key); } finally { lock.unlock(LockType.WRITE); } catch (final Throwable throwable) { put(new Element(key, null)); throw new LockTimeoutException("Could not update object for cache entry with key \"" + key + "\".", throwable);
/** * Element can never be null. Add a null guard just in case. * @param key */ protected void update(final Object key) { try { Ehcache backingCache = getCache(); final Element element = backingCache.getQuiet(key); if (element == null) { if (LOG.isDebugEnabled()) { LOG.debug(getName() + ": entry with key " + key + " has been removed - skipping it"); } return; } refreshElement(element, backingCache); } catch (final Exception e) { // Collect the exception and keep going. // Throw the exception once all the entries have been refreshed // If the refresh fails, keep the old element. It will simply become staler. LOG.warn(getName() + "Could not refresh element " + key, e); } }
Ehcache backingCache = getCache(); Element element = backingCache.get(key); element = super.get(key); } else { Sync lock = getLockForKey(key); try { lock.lock(LockType.WRITE); update(key); } finally { lock.unlock(LockType.WRITE); } catch (final Throwable throwable) { put(new Element(key, null)); throw new LockTimeoutException("Could not update object for cache entry with key \"" + key + "\".", throwable);
/** * Element can never be null. Add a null guard just in case. * @param key */ protected void update(final Object key) { try { Ehcache backingCache = getCache(); final Element element = backingCache.getQuiet(key); if (element == null) { if (LOG.isDebugEnabled()) { LOG.debug(getName() + ": entry with key " + key + " has been removed - skipping it"); } return; } refreshElement(element, backingCache); } catch (final Exception e) { // Collect the exception and keep going. // Throw the exception once all the entries have been refreshed // If the refresh fails, keep the old element. It will simply become staler. LOG.warn(getName() + "Could not refresh element " + key, e); } }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
Ehcache backingCache = getCache(); Element element = backingCache.get(key); element = super.get(key); } else { Sync lock = getLockForKey(key); try { lock.lock(LockType.WRITE); update(key); } finally { lock.unlock(LockType.WRITE); } catch (final Throwable throwable) { put(new Element(key, null)); throw new LockTimeoutException("Could not update object for cache entry with key \"" + key + "\".", throwable);
/** * Element can never be null. Add a null guard just in case. * @param key */ protected void update(final Object key) { try { Ehcache backingCache = getCache(); final Element element = backingCache.getQuiet(key); if (element == null) { if (LOG.isDebugEnabled()) { LOG.debug(getName() + ": entry with key " + key + " has been removed - skipping it"); } return; } refreshElement(element, backingCache); } catch (final Exception e) { // Collect the exception and keep going. // Throw the exception once all the entries have been refreshed // If the refresh fails, keep the old element. It will simply become staler. LOG.warn(getName() + "Could not refresh element " + key, e); } }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * * @param cache the raw Cache object, based on the configuration of this * FactoryBean * @return the (potentially decorated) cache object to be registered with the * CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * * @param cache the raw Cache object, based on the configuration of this * FactoryBean * @return the (potentially decorated) cache object to be registered with the * CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }