Search in sources :

Example 16 with CacheException

use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.

the class DefaultRenderingCache method initialize.

@Override
public void initialize() throws InitializationException {
    if (this.configuration.isEnabled()) {
        CacheConfiguration cacheConfiguration = new CacheConfiguration();
        cacheConfiguration.setConfigurationId(NAME);
        LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
        lru.setMaxEntries(this.configuration.getSize());
        lru.setLifespan(this.configuration.getDuration());
        cacheConfiguration.put(LRUEvictionConfiguration.CONFIGURATIONID, lru);
        try {
            this.cache.create(cacheConfiguration);
        } catch (CacheException e) {
            throw new InitializationException("Failed to initialize core rendering cache", e);
        }
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) LRUEvictionConfiguration(org.xwiki.cache.eviction.LRUEvictionConfiguration) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Example 17 with CacheException

use of org.xwiki.cache.CacheException in project xwiki-platform by xwiki.

the class XWikiGroupServiceImpl method initCache.

@Override
public synchronized void initCache(int iCapacity, XWikiContext context) throws XWikiException {
    try {
        CacheConfiguration configuration = new CacheConfiguration();
        configuration.setConfigurationId("xwiki.groupservice.usergroups");
        LRUEvictionConfiguration lru = new LRUEvictionConfiguration();
        lru.setMaxEntries(iCapacity);
        configuration.put(EntryEvictionConfiguration.CONFIGURATIONID, lru);
        this.memberGroupsCache = Utils.getComponent(CacheManager.class).createNewCache(configuration);
    } catch (CacheException e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_CACHE, XWikiException.ERROR_CACHE_INITIALIZING, "Failed to initialize 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)

Aggregations

CacheException (org.xwiki.cache.CacheException)17 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)15 InitializationException (org.xwiki.component.phase.InitializationException)8 LRUEvictionConfiguration (org.xwiki.cache.eviction.LRUEvictionConfiguration)7 XWikiException (com.xpn.xwiki.XWikiException)6 CacheFactory (org.xwiki.cache.CacheFactory)4 LRUCacheConfiguration (org.xwiki.cache.config.LRUCacheConfiguration)3 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 List (java.util.List)1 Test (org.junit.Test)1 CacheManager (org.xwiki.cache.CacheManager)1 MacroExecutionException (org.xwiki.rendering.macro.MacroExecutionException)1