@Override protected Ehcache decorateCache(Ehcache cache) { Ehcache decorated = super.decorateCache(cache); if (decorated instanceof BlockingCache) { ((BlockingCache) decorated).setTimeoutMillis(timeoutMillis); } return decorated; } }
protected void createCache(String name) { synchronized (this.getClass()) { cacheManager.addCache(name); final Ehcache cache = cacheManager.getEhcache(name); // default EHCache is non blocking. Since our impl always requires blocking cache wrap it here. final BlockingCache newBlockingCache = new BlockingCache(cache); newBlockingCache.setTimeoutMillis(getBlockingTimeout()); cacheManager.replaceCacheWithDecoratedCache(cache, newBlockingCache); } }
/** * Replace the cache with a BlockingCache decorated one if this has not been done yet. * The cacheLoaderTimeoutMillis of the original cache will be used as the timeoutMillis of the BlockingCache. * @param ehcache the original cache * @return a BlockingCache wrapping the original one */ protected BlockingCache replaceWithBlockingCacheIfNot(Ehcache ehcache){ if (ehcache instanceof BlockingCache){ return (BlockingCache) ehcache; } BlockingCache blockingCache = new BlockingCache(ehcache); blockingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, blockingCache); return blockingCache; }
/** * Create and return a reference to {@link Cache} object. * * @return instance of {@link Cache}. */ public static Cache createInstance(String name, net.sf.ehcache.CacheManager cacheManager) { net.sf.ehcache.Ehcache cache = cacheManager.getEhcache(name); if(cache == null) { String error = "createInstance cache: " + name + " is null"; throw new CfgRuntimeException(GlobalErrIds.FT_CACHE_NOT_CONFIGURED, error); } BlockingCache blockingCache = new BlockingCache(cache); blockingCache.setTimeoutMillis(60000); cacheManager.replaceCacheWithDecoratedCache(cache, blockingCache); return new EhCacheImpl(name, blockingCache); } }
this._cache.setTimeoutMillis(5000);
blockingCache.setTimeoutMillis( blockingTimeoutMillis );
Integer blockingTimeoutMillis = parseBlockingCacheTimeoutMillis(filterConfig); if (blockingTimeoutMillis != null && blockingTimeoutMillis > 0) { blockingCache.setTimeoutMillis(blockingTimeoutMillis);