use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class XWikiCacheServiceStub method newCache.
@Override
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);
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class XWikiCacheServiceStub method newLocalCache.
@Override
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);
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultDocumentCacheTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
this.cache = (DefaultDocumentCache<String>) getComponentManager().getInstance(DocumentCache.class);
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setConfigurationId("documentcachetest");
LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
this.cache.create(cacheConfiguration);
this.document = new XWikiDocument(new DocumentReference("wiki", "space", "page"));
this.document.setOriginalDocument(this.document.clone());
this.mockXWiki = getMockery().mock(XWiki.class);
getContext().setWiki(this.mockXWiki);
getMockery().checking(new Expectations() {
{
allowing(mockXWiki).getDocument(document.getDocumentReference(), getContext());
will(returnValue(document));
}
});
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class CacheImageStorage method initialize.
@Override
public void initialize() throws InitializationException {
CacheConfiguration configuration = new CacheConfiguration();
configuration.setConfigurationId("xwiki.plugin.formula");
try {
this.cache = this.cacheManager.createNewCache(configuration);
} catch (CacheException e) {
throw new InitializationException("Failed to create cache", e);
}
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultIconSetCache method initialize.
@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);
}
}
Aggregations