Search in sources :

Example 11 with CacheConfiguration

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);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) XWikiException(com.xpn.xwiki.XWikiException)

Example 12 with CacheConfiguration

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);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) XWikiException(com.xpn.xwiki.XWikiException)

Example 13 with CacheConfiguration

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));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) XWiki(com.xpn.xwiki.XWiki) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 14 with CacheConfiguration

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);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Example 15 with CacheConfiguration

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);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Aggregations

CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)19 CacheException (org.xwiki.cache.CacheException)14 LRUEvictionConfiguration (org.xwiki.cache.eviction.LRUEvictionConfiguration)9 InitializationException (org.xwiki.component.phase.InitializationException)7 XWikiException (com.xpn.xwiki.XWikiException)6 CacheFactory (org.xwiki.cache.CacheFactory)5 CacheManager (org.xwiki.cache.CacheManager)3 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 Before (org.junit.Before)2 Cache (org.xwiki.cache.Cache)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 Expectations (org.jmock.Expectations)1 LRUCacheConfiguration (org.xwiki.cache.config.LRUCacheConfiguration)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 IconSet (org.xwiki.icon.IconSet)1 NamedColorThemeReference (org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference)1 LESSSkinFileResourceReference (org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference)1 FSSkinReference (org.xwiki.lesscss.internal.skin.FSSkinReference)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1