use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.
the class ParseGroovyFromString method initCache.
private void initCache(int iClassCapacity, XWikiContext context) throws XWikiException {
try {
CacheConfiguration configuration = new LRUCacheConfiguration("xwiki.groovy.class", iClassCapacity);
this.classCache = this.cacheManager.createNewLocalCache(configuration);
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initilize caches", e);
}
}
use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.
the class XWikiCacheServiceStub method newCache.
@Override
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);
}
}
use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.
the class DefaultOfficeResourceViewer method initialize.
@Override
public void initialize() throws InitializationException {
try {
LRUCacheConfiguration attachmentConfig = new LRUCacheConfiguration(MODULE_NAME + ".attachment", 50);
this.attachmentCache = this.cacheManager.createNewCache(attachmentConfig);
// We have no idea when to invalidate the cache so lets at least put a time to live
LRUCacheConfiguration exteralConfig = new LRUCacheConfiguration(MODULE_NAME + ".external", 50, 3600);
this.externalCache = this.cacheManager.createNewCache(exteralConfig);
} catch (CacheException e) {
throw new InitializationException("Failed to create caches.", e);
}
}
use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.
the class FeedPlugin method initCache.
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.setMaxIdle(this.refreshPeriod);
configuration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
CacheManager cacheManager = Utils.getComponent(CacheManager.class);
this.feedCache = cacheManager.createNewLocalCache(configuration);
} catch (CacheException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to create cache");
}
}
use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.
the class DocumentTranslationBundleFactory method initialize.
@Override
public void initialize() throws InitializationException {
// Cache
CacheConfiguration cacheConfiguration = new CacheConfiguration("localization.bundle.document");
try {
this.onDemandBundleCache = this.cacheManager.createNewCache(cacheConfiguration);
} catch (CacheException e) {
this.logger.error("Failed to create cache [{}]", cacheConfiguration.getConfigurationId(), e);
}
// Load existing translations from main wiki, wait for WikiReaderEvent for other wikis
loadTranslations(this.wikiManager.getMainWikiId());
// Listeners
this.observation.addListener(this.listener);
this.observation.addListener(this.wikilistener);
}
Aggregations