use of org.xwiki.cache.config.CacheConfiguration 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.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method setUp.
@Before
public void setUp() throws Exception {
cacheManager = mocker.getInstance(CacheManager.class);
cache = mock(Cache.class);
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
CacheConfiguration configuration = new CacheConfiguration("lesscss.skinfiles.cache");
when(cacheFactory.<String>newCache(eq(configuration))).thenReturn(cache);
cacheKeyFactory = mocker.getInstance(CacheKeyFactory.class);
LESSSkinFileResourceReference lessSkinFileResourceReference = new LESSSkinFileResourceReference("lessResource", null, null);
when(cacheKeyFactory.getCacheKey(eq(lessSkinFileResourceReference), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("12_lessResource_4_skin_10_colorTheme");
}
use of org.xwiki.cache.config.CacheConfiguration 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.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultIconSetCacheTest method setUp.
@Before
public void setUp() throws Exception {
cacheManager = mocker.getInstance(CacheManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
cache = mock(Cache.class);
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
CacheConfiguration configuration = new CacheConfiguration("iconset");
when(cacheFactory.<IconSet>newCache(eq(configuration))).thenReturn(cache);
}
use of org.xwiki.cache.config.CacheConfiguration in project xwiki-platform by xwiki.
the class DefaultDocumentCache method create.
@Override
public void create(CacheConfiguration cacheConfiguration) throws CacheException {
this.name = cacheConfiguration.getConfigurationId();
this.cache = this.cacheManager.createNewCache(cacheConfiguration);
CacheConfiguration mappingCacheConfiguration = (CacheConfiguration) cacheConfiguration.clone();
mappingCacheConfiguration.setConfigurationId(cacheConfiguration.getConfigurationId() + ".mapping");
this.mappingCache = this.cacheManager.createNewCache(mappingCacheConfiguration);
this.observationManager.addListener(this.listener);
}
Aggregations