@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(CACHE_NAME); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize the notification filters preferences cache [%s].", CACHE_NAME), e); } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(LESS_FILES_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize LESS skin files cache [%s].", LESS_FILES_CACHE_ID), e); } } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e); } } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(LESS_FILES_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize LESS skin files cache [%s].", LESS_FILES_CACHE_ID), e); } } }
/** * Lookup the cache component with provided hint and create a new cache. * * @param <T> the class of the data stored in the cache. * @param config the cache configuration. * @param cacheHint the role hint to lookup. * @return a new {@link Cache}. * @throws CacheException error when creating the cache. */ public <T> Cache<T> createNewCache(CacheConfiguration config, String cacheHint) throws CacheException { CacheFactory cacheFactory; try { cacheFactory = this.componentManager.getInstance(CacheFactory.class, cacheHint); } catch (ComponentLookupException e) { throw new CacheException("Failed to get cache factory for role hint [" + cacheHint + "]", e); } return cacheFactory.newCache(config); } }
/** * Lookup the cache component with provided hint and create a new cache. * * @param <T> the class of the data stored in the cache. * @param config the cache configuration. * @param cacheHint the role hint to lookup. * @return a new {@link Cache}. * @throws CacheException error when creating the cache. */ public <T> Cache<T> createNewCache(CacheConfiguration config, String cacheHint) throws CacheException { CacheFactory cacheFactory; try { cacheFactory = this.componentManager.getInstance(CacheFactory.class, cacheHint); } catch (ComponentLookupException e) { throw new CacheException("Failed to get cache factory for role hint [" + cacheHint + "]", e); } return cacheFactory.newCache(config); } }
@Override public void initialize() throws InitializationException { try { CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); this.cache = cacheFactory.newCache(configuration); } catch (ComponentLookupException | CacheException e) { throw new InitializationException("Failed to initialize the IconSet Cache.", e); } }
@Override public void initialize() throws InitializationException { try { // Create the cache CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID); CacheFactory cacheFactory = cacheManager.getCacheFactory(); super.cache = cacheFactory.newCache(configuration); // The Color Theme only depends on colors which do not depend on the XWikiContext. So we don't handle the // XWikiContext in this cache. super.isContextHandled = false; } catch (ComponentLookupException | CacheException e) { throw new InitializationException( String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e); } } }
public XWikiCache newLocalCache() throws XWikiException { try { return new XWikiCacheStub(this.localCacheFactory.newCache(new CacheConfiguration())); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
public XWikiCache newCache(String cacheName) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId(cacheName); try { return new XWikiCacheStub(this.cacheFactory.newCache(configuration)); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
this.imageCache = context.getWiki().getLocalCacheFactory().newCache(configuration); } catch (CacheException e) { LOG.error("Error initializing the image cache.", e);
public XWikiCache newLocalCache(int capacity) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(capacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); try { return new XWikiCacheStub(this.localCacheFactory.newCache(configuration)); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
public XWikiCache newCache(String cacheName, int capacity) throws XWikiException { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId(cacheName); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(capacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); try { return new XWikiCacheStub(this.cacheFactory.newCache(configuration)); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } }
private void ensureVirtualWikiMapExists() throws XWikiException { synchronized (this) { if (this.virtualWikiMap == null) { int iCapacity = 1000; try { String capacity = Param("xwiki.virtual.cache.capacity"); if (capacity != null) { iCapacity = Integer.parseInt(capacity); } } catch (Exception e) { } try { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId("xwiki.virtualwikimap"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(iCapacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.virtualWikiMap = getCacheFactory().newCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create new cache", e); } } } }
public void initCache(int iCapacity, XWikiContext context) throws XWikiException { try { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId("xwiki.renderingcache"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(iCapacity); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.cache = context.getWiki().getCacheFactory().newCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache"); } }
public void initCache(int iCapacity, XWikiContext context) throws XWikiException { try { CacheConfiguration configuration = new CacheConfiguration(); configuration.setConfigurationId("xwiki.plugin.feedcache"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(iCapacity); lru.setTimeToLive(this.refreshPeriod); configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); this.feedCache = context.getWiki().getLocalCacheFactory().newCache(configuration); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache"); } }
public void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context) throws XWikiException { CacheFactory cacheFactory = context.getWiki().getCacheFactory(); try { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setConfigurationId("xwiki.store.pagecache"); LRUEvictionConfiguration lru = new LRUEvictionConfiguration(); lru.setMaxEntries(capacity); cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); Cache<XWikiDocument> pageCache = cacheFactory.newCache(cacheConfiguration); setCache(pageCache); cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setConfigurationId("xwiki.store.pageexistcache"); lru = new LRUEvictionConfiguration(); lru.setMaxEntries(pageExistCacheCapacity); cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru); Cache<Boolean> pageExistcache = cacheFactory.newCache(cacheConfiguration); setPageExistCache(pageExistcache); } catch (CacheException e) { throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initialize cache", e); } }